Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application Initialization Module for IIS 7.5 issue

As a part of Proof of Concept utilizing the Application Initialization Module for IIS 7.5 to increase the speed of web apps initialization, I have created a simple web application hosted on IIS 7.5 (Windows Server 2008 R2) with SSL enabled. Please see global and local settings below.

If I understand correctly the way the Application Initialization Module works, I am expecting IIS to issue a request to appinit.aspx (https://localhost/alwaysrunning/appinit.aspx) to initialize the web application. This is however never happening.

Any ideas?

What is the purpose of the attribute initializationPage?

Any help with this would be greatly appreciated.

EDIT: When I disable SSL the Application Initialization Module issues a request to appinit.aspx as expected. I need to get this to work with SSL enabled though.

Zen

Global settings in the applicationHost.config file:

<add name="appinit" autoStart="true" startMode="AlwaysRunning">
    <recycling logEventOnRecycle="Time, Requests, Schedule, Memory, IsapiUnhealthy, OnDemand, ConfigChange, PrivateMemory">
        <periodicRestart requests="0" time="00:05:00">
            <schedule>
                <clear />
            </schedule>
        </periodicRestart>
    </recycling>
    <processModel identityType="NetworkService" idleTimeout="00:00:00" />
</add>

<application path="/alwaysrunning" preloadEnabled="true" applicationPool="appinit">
    <virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\alwaysrunnig" />
</application>

Local settings in application's web.config file:

<applicationInitialization remapManagedRequestsTo="splashscreen.htm" skipManagedModules="true" >
    <add initializationPage="/appinit.aspx" />
</applicationInitialization> 
like image 501
UncleZen Avatar asked Oct 26 '12 14:10

UncleZen


People also ask

What is application initialization in IIS?

IIS Application Initialization allows website administrators to configure a web application to be pre-loaded as soon as the worker process starts, before the first request arrives. By pre-loading the application, the worker process is able to reduce the time it takes to respond to the first request.

What is preload enabled in IIS?

Setting preloadEnabled to "true" tells IIS 8.0 that it sends a "fake" request to the application when the associated application pool starts up. That is why in the previous step we set the application pool's startMode to "AlwaysRunning".

What is app init?

Creates a directory (if not already existing) on the local filesystem for storing end user data and customizeable app config. use cases: you want to expose some configuration values to the end user. you want to make it easy for users to find and make backups of key application data (ie- a database)


1 Answers

(I know, stale question, but it's unanswered & came up in my own Google search on the subject.)

Refer to the following article from Microsoft Support: Application Initialization module fails when web site requires SSL (KB2843964). Quote:

Cause

This behavior is by design.

Resolution

To workaround this limitation, you may consider enabling HTTP (uncheck the "Require SSL" setting in IIS Manager/SSL Settings) and use a URL Rewrite rule to redirect HTTP requests to HTTPS with the exception of the request coming from the warmup module :

 <rewrite>
   <rules>
     <rule name="No redirect on warmup request (request from localhost with warmup user agent)" stopProcessing="true">
       <match url=".*" />
       <conditions>
         <add input="{HTTP_HOST}" pattern="localhost" /> 
         <add input="{HTTP_USER_AGENT}" pattern="Initialization" /> 
       </conditions> 
       <action type="Rewrite" url="{URL}" /> 
     </rule> 
     <rule name="HTTP to HTTPS redirect for all requests" stopProcessing="true"> 
       <match url="(.*)" /> 
       <conditions> 
         <add input="{HTTPS}" pattern="off" /> 
       </conditions> 
       <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> 
     </rule> 
   </rules> 
 </rewrite>

Gotta love "This behavior is by design." Sigh. Sadly, the top search results I found about this Application Initialization feature fail to mention this limitation — unless one interprets "HTTP request" as strictly meaning non-secure requests.

like image 200
Chris W. Rea Avatar answered Sep 29 '22 10:09

Chris W. Rea