通常情况下我们在调用接口的时候会返回一个回调地址【(redirect_uri )比如QQ、微博登录接口等】,而这个回调地址地址就这样暴露显而易见不安全,会对我们的程序安全构成严重威胁,那么我们可以使用Encoding()将回调地址加密,加密后这个地址会显示为乱码,但不会影响地址的解析,这样就完美的解决了这个问题。
**没加密前的写法
string WB_Url = string.Format("{0}?client_id={1}&response_type=code&redirect_uri={2}", apiurl, AppKey, redirect_uri));
**用Encoding()方法加密后的写法
string WB_Url = string.Format("{0}?client_id={1}&response_type=code&redirect_uri={2}",apiurl,AppKey, HttpUtility.UrlEncode(redirect_uri, Encoding.UTF8));
//加密后的结果为乱码:
这样就大功告成了!