在切换页面请求前的准备工作是先申请443端口下的安全证书,这里不做详解
可在相关网站上进行申请。
在切换http和https可以使用iis7的url重写功能,也可以使用其它的一些插件。
这里我使用的是SecuritySwitch v4.2.0.0 ;可在我的博客资源中下载,也可以在网上查找下载;具体代码如下
<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- SecuritySwitch配置 -->
<section name="securitySwitch" type="SecuritySwitch.Configuration.Settings, SecuritySwitch" />
</configSections>
<!-- SecuritySwitch配置 -->
<securitySwitch baseInsecureUri="http://www.futureyun.cn" baseSecureUri="https://www.futureyun.cn" xmlns="http://SecuritySwitch-v4.xsd" mode="On" bypassSecurityWarning="true">
<paths>
<!-- 默认域名绑定使用https可以进行如下处理;关键代码matchType="Exact"必须加上否则,整个网站全部会被定义成https -->
<add path="/" matchType="Exact" />
<!-- 对应需要改变的页面的地址 -->
<add path="~/Register.aspx" />
<!-- 若页面引用到 js或者css 必须也在这里进行路径处理,否则相应的js和css会失效 -->
<add path="~/Scripts/" />
</paths>
</securitySwitch>
<system.web>
</sessionState>
</system.web>
<!-- IIS7.X+集成模式 部署到iis中需要取消注释 若是经典模式可到相关SecuritySwitch讲解下了解修改-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="SecuritySwitch" type="SecuritySwitch.SecuritySwitchModule, SecuritySwitch" />
</modules>
</system.webServer>
</configuration>
此处仅贴出需要使用改变https的部分;若有疑问可在评论区留言。。。