IIS Rewrite module – redirect all Http calls to Https – breaks debugging in Visual Studio

Posted by admin on August 23rd, 2011

iis7 150x150 IIS Rewrite module   redirect all Http calls to Https   breaks debugging in Visual StudioFirst you’ll need to install the URL rewrite module.  See link for detailed information on URL rewrite.

1
2
3
4
5
6
7
8
9
10
11
12
<rewrite>
    <rules>
	<rule name="Redirect to https" enabled="true">
	    <match url="(.*)" />
	    <conditions>
	        <add input="{SERVER_PORT}" pattern="443" negate="true" />
	    </conditions>
	    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" 
                    appendQueryString="false" />
	</rule>
    </rules>
</rewrite>

This rule will redirect all Http calls to Https, except calls to Https (otherwise you would end up in an endless loop). Some good info on Url Rewrite Module can be found here.

I you haven’t installed the Url Rewrite Module, your site will crash on the rewrite section.

Another thing we noticed is that debugging in VS2010/2008 with rewrite enabled (enabled =”true”) doesn’t work. Seems to be a bug. More info here and here.

Seperating Environment Specific Information – Web.config

Posted by admin on October 2nd, 2008

I have these four sections in my web.config that needed to be defined out of the web.config. This is very usefull when doing an update at a customer’s environment. The only thing I need to copy is the web.config itself without the four other config files that are specific to the environment running at the customer.

In Web.config:

1
2
3
4
  <log4net configSource="WebLog4Net.config" /> 
  <connectionStrings configSource="WebConnectionString.config" />
  <SubSonicService configSource="WebSubSonicService.config" /> 
  <appSettings configSource="WebAppSettings.config" />

WebConnectionStrings.config:

1
2
3
4
5
6
<connectionStrings>
  <add name="TLVSRVDevConnection" 
       connectionString="..."/>
  <add name="TLVSRVProdConnection" 
       connectionString="..."/>
</connectionStrings>
pixel Seperating Environment Specific Information   Web.config

Copyright © 2007 Lieven Cardoen. All rights reserved.