1

I have a client whom has a site configured in iis7.5 running asp.net 4.0. The site is configured with a static IP address, with a valid wildcard cert, it has headers setup as wildcard leavemanagement.co.za and www.leavemanagement.co.za.

The clients access the application by using their company name as a sub domain prefix to get their login, etc correctly. I think the app uses the prefix as a form of identification to return the correct info once they login. So for example you goto http://demo.leavemanagement.co.za or https://leavemanagement.co.za to be able to get your login, if you use either of these ways manually the site works 100% fine.

I tried to use various web.config rewrite rules to automate the switch to https automatically, but all it does is cause an application error. as below

Server Error in '/' Application.

Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

  • Exception Details:

System.NullReferenceException: Object reference not set to an instance of an object.

  • Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

  • Stack Trace:

     [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
    

the rewrite rules i have tried have been numerous, the last one we have tried is this

        <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>

If someone can help me please..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.