Mike Flynn
Mike Flynn

Reputation: 24325

applicationInitialization causing 500.21 error in IIS Express

Can I not have this element in my web.config and run it in IIS Express?

HTTP Error 500.21 - Internal Server Error The specified handler mapping is incorrect.

<system.webServer>
<applicationInitialization doAppInitAfterRestart="true" skipManagedModules="false" remapManagedRequestsTo="WarmUp.html">
  <add initializationPage="/"/>
</applicationInitialization>

Upvotes: 1

Views: 610

Answers (2)

Aveer28
Aveer28

Reputation: 197

For IIS Express you can add the following attributes to the applicationhost.config file (location differs dependent on VS version)

Add attribute startMode to the application pool

<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" startMode="AlwaysRunning" />

Add attribute preloadEnabled to application

<site name="WebApplication3" id="2">
                <application path="/" applicationPool="Clr4IntegratedAppPool" preloadEnabled="true" >
                    <virtualDirectory path="/" physicalPath="WebApplication3" />
                </application>
                <bindings>
                    <binding protocol="http" bindingInformation="*:59141:localhost" />
                    <binding protocol="https" bindingInformation="*:44367:localhost" />
                </bindings>
            </site>

In the web.config add the section

<system.webServer>
    <applicationInitialization remapManagedRequestsTo="Startup.htm" skipManagedModules="true" doAppInitAfterRestart="true">
      <add initializationPage="/" />
    </applicationInitialization>
  </system.webServer>

Upvotes: 2

Brando Zhang
Brando Zhang

Reputation: 27997

Yes, you could remove it from your web.config file. In my opinion, the applicationInitialization tag is used to warm up your application to achieve starting up application more quickly.

Details, you could refer to below article: https://learn.microsoft.com/en-us/iis/configuration/system.webserver/applicationinitialization/

Upvotes: 1

Related Questions