public static string ChangeUriToHttps(HttpRequest request)
{
string uri = request.Url.AbsoluteUri;
if (!IsRequestSecure(request))
uri.Replace("http", "https");
return uri;
}
If I send in a request that has a uri like this:
http://localhost/AppName/somepage.aspx
it doesn't replace the http with https.
common mistake. Strings are immutable. This means the original object can't be modified.
public static string ChangeUriToHttps(HttpRequest request)
{
string uri = request.Url.AbsoluteUri;
if (!IsRequestSecure(request))
uri = uri.Replace("http", "https");
return uri;
}
精彩评论