zoukankan      html  css  js  c++  java
  • 关于解决CommunityServer使用中文名字注册自动创建博客和相册的问题

    有人用拼音规则,但是会遇到重音的问题,例如“中文名”和“钟文名”的拼音就是一样的会造成谁后面注册就无法自动创建博客和相册的问题。

    找到Global.cs 文件的 ValidateApplicationKey 函数 把只要是中文或者其他文字都会被替换成用时间叫毫秒的表现形式

               //自己的解决方法

                formattedKey = appKey.Trim().Replace(" ", "_").ToLower();
                formattedKey = System.Text.RegularExpressions.Regex.Replace(formattedKey, "[^0-9a-zA-Z_\\-]", "");

                if ((formattedKey == null) || (formattedKey == string.Empty))
                {
                    //前提条件是服务器的时间能正常工作
                    //否则则会创建出重复的key导致失效,有这种问题的话可以自己创建GUID来用就什么问题都解决了。
                    string key = DateTime.Now.ToString() + DateTime.Now.Millisecond.ToString();
                    key = key.Replace(" ", "")
                            .Replace(":", "")
                            .Replace("-", "");
                    formattedKey = key;
                }
                formattedKey = Globals.UrlEncode(formattedKey); 

                return formattedKey == appKey;

    替换后用“中文名”和“钟文名”注册帐户都无所谓了,因为这里已经去掉拼音的规则了,而且不会重复。如果大家还有什么更好的方法请指教!

  • 相关阅读:
    1063. Set Similarity
    A1047. Student List for Course
    A1039. Course List for Student
    最大公约数、素数、分数运算、超长整数计算总结
    A1024. Palindromic Number
    A1023. Have Fun with Numbers
    A1059. Prime Factors
    A1096. Consecutive Factors
    A1078. Hashing
    A1015. Reversible Primes
  • 原文地址:https://www.cnblogs.com/Bruce_H21/p/674762.html
Copyright © 2011-2022 走看看