【发布时间】:2010-09-29 16:45:05
【问题描述】:
我正在使用这个简单的代码在我的结算登录页面上将 http 重定向到 https:
if (!Request.IsSecureConnection)
{
// send user to SSL
string serverName =HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
string filePath = Request.FilePath;
Response.Redirect("https://" + serverName + filePath);
}
如果网址中还没有 www,我还需要它来检查网址并将其添加到网址中。我需要在此代码中添加什么来完成此操作?
【问题讨论】:
-
您不应该对服务器名称进行编码。
标签: c# asp.net http redirect https