Wednesday 12 March 2008

Migrating ASP.NET Site from IIS 6.0 to IIS 7.0

1. Remove the built-in Membership, Role and Profile providers

If you are configuring your own Membership, Role or Profile providers with your own database connection string, make sure you remove the built-in ones or you may get an exception about not being able to connect to "LocalSqlServer". Which is the connection string used in machine.config for the stock providers. This did not happen under IIS6. So it turns out the bolded lines become very important under IIS7.

<membership defaultProvider="MembershipSqlProvider"...>
<providers>
<remove name="AspNetSqlMembershipProvider"/>
<add name="MembershipSqlProvider"
:
connectionStringName="MyDatabaseConnection"/>
</providers>
</membership>

<roleManager defaultProvider="RoleManagerSqlProvider"...>
<providers>
<remove name="AspNetSqlRoleProvider"/>
<add name="RoleManagerSqlProvider"
:
connectionStringName="MyDatabaseConnection"/>
</providers>
</roleManager>

<profile defaultProvider="SqlProfileProvider">
<providers>
<remove name="AspNetSqlProfileProvider"/>
<add name="SqlProfileProvider"
:
connectionStringName="MyDatabaseConnection"/>
</providers>
</profile>

2. Move your Modules and Handlers to the <system.webServer> section

This one took me a while to figure out, but it shouldn't have. I had a custom module that was redirecting to secure pages when necessary, and it was not firing under IIS7. So I instrumented it up with log statements, and still nothing. A quick search turned up Rick Strahl's post on this.

<configuration>

<system.web>
<httpModules>
MODULES DON'T GO HERE ANYMORE
</httpModules>
<httpHandlers>
HANDLERS DON'T GO HERE ANYMORE
</httpHandlers>
</system.web>

<system.webServer>
<modules>
FOR IIS7, MODULES GO HERE NOW
</modules>
<handlers>
FOR IIS7 HANDLERS GO HERE NOW
</handlers>
</system.webServer>

<configuration>

Share:

0 comments:

Post a Comment