http 如何自动跳转到 https 急
配置好了证书服务了现在想输入 http:\\www.abc.com 自动跳转到 https:\\www.abc.com 。
查了很多资料都说的不详细,我刚用.net c#,,我在tomcat 里头配置过,,就改web.xml就行了,,我估计在.net里头应该 和web.config有关,但不知道怎么做
有大哥给了下面的代码:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (!Context.Request.IsSecureConnection)
{
// string strOrg=Context.Request.Url.ToString().ToLower();
// StreamWriter sw=new StreamWriter(Server.MapPath("yj.txt"));
// sw.WriteLine(strOrg);
// sw.Close();
string strUrl=Context.Request.Url.ToString().ToLower().Replace("http://","https://");
Response.Redirect(strUrl);
}
}
不知道怎么用,放在哪里加栽,,请过来人指教,详细点,。net 我不熟,,先谢过了