Home > Net >  When the Web API password contains special characters (@), can't get the Http Response
When the Web API password contains special characters (@), can't get the Http Response

Time:02-27

The following is my usage:

 HttpWebRequest request=HttpWebRequest. Create (Url) as HttpWebRequest; 
The string result=null;
Request. The Method="GET";//method
Request. The KeepAlive=false;//whether the attachment
Request. The ContentType="application/x - WWW - form - urlencoded";

String username=param. LoginAccount;
String password=param. LoginPW;
String encoded=System. The Convert. ToBase64String (new ASCIIEncoding () GetBytes (username + + password ":"));
Request. Headers. The Add (" Authorization ", "Basic" + encoded);


Elected to use the account password contains special characters (@), will fail,
Put this account in the special characters (@) to remove the password, will succeed,

Would like to ask how to deal with this problem? Or can you provide the key word? (find out earlier, but not so to find this kind of problem...). Thank you.
  •  Tags:  
  • C#
  • Related