Thursday, July 17, 2008

ASP.NET 2.0 Web Request Timeout - Configuring Long Running Web Request

In ASP.NET both a Web request (ASPX) pages together with Web Service Pages (ASMX) constitute a web request.

All web requests have a request timeout.

The ASP.NET script timeout (Request Timeout) also depends on the compilation node set in web.config.

When debug set to true

<compilation debug="true" />


The value for request timeout is 30,000,000 seconds (close to a year 31,536,000 Seconds)

This value is internal and can be found on the page init using


private int timeout = 0;


protected void Page_Init(object sender, EventArgs e)

{

timeout = Server.ScriptTimeout;

}

protected void Page_Load(object sender, EventArgs e)

{

Response.Write("Timeout:" + timeout);

}

When debug set to false

<compilation debug="false" />

The value for request timeout is 110 seconds

This value is config setting and can be found in machine level web.config (web.config.comments) under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG

<httpRuntime
executionTimeout = "110" [in Seconds][number]



With regard to the production environment the value should always be
<compilation debug="false" />

With regard to long running web request I have addressed these three scenarios

1. Long running Web Request Call
2. Web Request Call which in turn calls a long running Web Service Synchronously
3. Web Request Call which in turn calls a long running Web Service Asynchronously


Scenario:1 Long running Web Request Call
In order to make a longer web request call you need to override the <httpRuntime node and set the executionTimeout to a higher value depending on your need.

<httpRuntime
executionTimeout = "180" [in Seconds][number]


Setting present under system.web on the Web.config of the current application.

Scenario:2. Web Request Call which in turn calls a long running Web Service Synchronously
Since there are two applications involved here (one Web Application and the other Web Service Application) you need to increase the executionTimeout in both the applications web.config to a value equal to the longest time taken between them.


<httpRuntime
executionTimeout = "240" [in Seconds][number]


Now that we have increased the request time we now have to tell the web request page to increase the webproxy call time from the default 100 Seconds.

This is specified in the proxy created for the webservice


CalculatorService.CalculatorWS calculator;
calculator = new WebPlayground2005.CalculatorService.CalculatorWS();
calculator.Timeout = 190000 //milliseconds;


Scenario:3. Web Request Call which in turn calls a long running Web Service Asynchronously
Fortunately this is easier and require only the web.config of the web services application having an overide setting for

<httpRuntime
executionTimeout = "190" [in Seconds][number]


ASP.NET is clever enough to increase the web application request timeout till the asynchronous call is returned from the web service.

Happy Programming,
Anton

Labels:

Wednesday, July 09, 2008

Using Microsoft Certificate Services - How to set up SSL by using IIS

For the developer machines running Windows XP and IIS 5.1 the choice for setting up HTTPS protocol is very limited.

Verisign has a trial certificate which is valid for 14 days and had to be renewed with diferent credentials after expiry.
More info is available at Free SSL Trial Certificate

Luckily for those who have Windows 2003 Server (Enterprise or Standard) Microsoft has its own CA services. Install the CA on your Development Windows 2003 Server depending on your configuration.

Follow the instruction given for setting up SSL on IIS 5.

Sometimes on XP you would get this error Certificate Authority. Keyset does not exist. Resolve as instructed.

Now when you access the URL. IE 7 would throw the Certificate Error Navigation Blocked. Please note Use your machine name and not localhost for https



Even if you add the certificate to the Trusted CA Root in IE the error would still be repeated as the certificate issued by Microsoft Certificate Services follows a concept call Certificate Chaining

In order to make IE 7 relax its policy you need to install the Certificate Chain from the Certificate Services Web Server.

Navigate to the Certificate Server and click on Install this CA Certificate Chain as shown in the figure.



Now navigate to your local url and the lock symbol should appear without the green background.


Happy Programming
Anton

Labels: