你如何将HTTP请求到HTTPS URL [英] How do you forward http request to a https url
本文介绍了你如何将HTTP请求到HTTPS URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
像这个问题说,如果我有一个页面的请求我的网站上这样
Like the question says, if I have a request for a page on my site like this
http://somename.something.here/Dada.aspx
要像这样
https://somename.something.here/Dada.aspx
https://somename.something.here/Dada.aspx
推荐答案
我preFER于(a)不重定向本地连接(以缓解VS开发中),和(b)使用UriBuilder而不是字符串。更换,因为它是一个有点更精确。
I prefer to (a) not redirect local connections (to ease development under VS), and (b) use a UriBuilder instead of a string.Replace as it's a bit more exact.
if (!Request.IsLocal && !Request.IsSecureConnection) {
var ub = new UriBuilder(Request.Url);
ub.Scheme = Uri.UriSchemeHttps;
ub.Port = -1; // use default port for scheme
Response.Redirect(ub.Uri.AbsoluteUri, true);
return;
}
这篇关于你如何将HTTP请求到HTTPS URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文