iis 7.5 http到httpsredirect不工作,导致错误

我有一个客户端,他在iis7.5中configuration了一个运行asp.net 4.0的站点。 该站点configuration了一个静态IP地址和一个有效的通配符证书,它的标头设置为通配符leavemanagement.co.za和www.leavemanagement.co.za。

客户端通过使用他们的公司名称作为子域名前缀来正确地访问应用程序以获得他们的login等。 我认为应用程序使用前缀作为身份识别的forms来返回正确的信息,一旦他们login。 因此,例如,您可以通过http://demo.leavemanagement.co.za或https://leavemanagement.co.za来获取您的login信息,如果您使用这两种方式中的任何一种,则该网站可以100%正常工作。

我试图使用各种web.config重写规则来自动切换到https自动,但它所做的是导致应用程序错误。 如下

Server Error in '/' Application. 

你调用的对象是空的。 说明:执行当前Web请求期间发生未处理的exception。 请查看堆栈跟踪,了解有关错误的更多信息以及源代码的位置。

  • exception详情:

System.NullReferenceException:未将对象引用设置为对象的实例。

  • 源错误:

在执行当前Web请求期间生成未处理的exception。 有关exception的来源和位置的信息可以使用下面的exception堆栈跟踪来标识。

  • 堆栈跟踪:

      [NullReferenceException: Object reference not set to an instance of an object.] Leave.Core.Security.FormsAuthenticationUserStateModule.PreSendRequestHeaders(Object sender, EventArgs e) +65 System.Web.SendResponseExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +137 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69 

我所尝试过的重写规则已经很多了,最后一个我们试过的是这个

  <rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> </rule> </rules> <outboundRules> <rule name="Add Strict-Transport-Security when HTTPS" enabled="true"> <match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" /> <conditions> <add input="{HTTPS}" pattern="on" ignoreCase="true" /> </conditions> <action type="Rewrite" value="max-age=31536000" /> </rule> </outboundRules> </rewrite> 

如果有人能帮助我