mvc里部分页面需要跳转到https,怎么处理比较好
1个回答
展开全部
好,直接上代码:
string url = Request.Path.ToLower();
switch (Request.Url.Scheme)
{
case "https":
if (ConfigurationManager.AppSettings["https"] == "1" && (url.Contains("/personal/") || url.Contains("/admin/")))
{
}
else
{
url = "http://" + Request.Url.Host + Request.Url.PathAndQuery;
Response.Redirect(url);
Response.End();
}
break;
case "http":
if (ConfigurationManager.AppSettings["https"] == "1" && (url.Contains("/personal/") || url.Contains("/admin/")))
{
url = "https://" + Request.Url.Host + Request.Url.PathAndQuery;
Response.Redirect(url);
Response.End();
}
break;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询