2007年8月31日 星期五

asp.net 2.0驗證網址如果是http就導到https , 使用C#

asp.net 2.0驗證網址如果是http就導到https , 使用C#

protected void Page_Load(object sender, EventArgs e)
{
//如果是http就導到https,
if (Request.ServerVariables["HTTPS"].ToString() == "off")
{
Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri.Replace("http:", "https:"));
}

}



protected void Page_Load(object sender, EventArgs e)
{
//如果是https就導到http
if (Request.ServerVariables["HTTPS"].ToString() == "on")
{
Response.Redirect(HttpContexurrent.Request.Url.AbsoluteUri.Replace("https:", "http:"));
}
}

沒有留言: