且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

确保页面只能通过SSL访问

更新时间:2023-12-03 09:19:28

这一般会被通过IIS配置或ISAPI筛选器处理,但如果你想这样做在应用code,你可以把东西像这样在你的母版页的Page_Init事件......

This would generally be handled via IIS configuration or with an ISAPI filter, but if you want to do it in the application code, you could put something like this in the Page_Init event of your master page...

If Not Request.IsSecure
    Response.Redirect(Request.Url.AbsoluteUri.Replace("http://", "https://"))
End If