Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

Monday, July 4, 2011

Fixing the error: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

In trying to setup a site on a Windows 2008 server, I ran into the following error message

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Searching the forums suggested running aspnet_regiis.exe with the -i option.
Running aspnet_regiis resulted in an error, the details of which could be found in a log file it generates. The log file had the following message

Failure Changing IIS ApplicationHost.config: IIS7Register failed with HRESULT 800700b7: 'Cannot create a file when that file already exists

I was able to fix the above error following the steps outlined in this blog article. The article recommends replacing %windir% with the absolute path "C:\Windows" in isapiCgiRestriction section of \windows\system32\inetsrv\config\applicationHost.config for .NET 4.0. The replacement is not required for .NET 2.0. Strange, but it worked. Running aspnet_regiis.exe after making this change resulted in successful execution and also fixed the "bad module" error!!

Monday, October 6, 2008

InfoCard download issue & response caching.

I have been studying the Zermatt code samples over the weekend in order to see how I can issue a managed card to an authenticated user of my web application that uses Windows Live Id authentication service. So after a user is authenticated, there is a button to be clicked to download the infocard. When I tested this on Firefox 3.0, the download worked fine. But on IE 7, I got an error message.

---------------------------
Windows Internet Explorer
---------------------------
Internet Explorer cannot download signin.aspx from localhost. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
---------------------------
OK
---------------------------

This was happening because of the following statement in Page Load event
Response.Cache.SetCacheability(HttpCacheability.NoCache);
was causing the download of the infocard to fail.

What does this statement do?
With this statement in the code, the response sent back to the client has "Cache-Control: no-cache" in the header.

Why should this error occur on IE, but not firefox?
IE, probably, handles "no-cache" setting without errors when the response is "text/html" encoded. In my case, I was returning a "application/x-informationcardfile" in the response and I guess IE threw up the error message since it could not find how not to cache this response.
Firefox 3.0 just ignores the cache-control HTTP header.

I replaced the offending statement with
Response.Cache.SetNoStore();
and the file download works fine on both IE & Firefox.

References:
1. File download problem with Response.Cache.SetCacheability
2. Cache directives ignored by Firefox in ASP.NET caching.

Wednesday, October 1, 2008

Random page selection for Load Testing

How should I design a load test for a scenario where a user can randomly hit one page from a given set of unsecure pages maintained on my web server? So at any point of time there could be 'x' no. of users, each accessing one page from the 'y' no. of pages residing on my web server. First I wrote a web test that will simulate 1 user accessing a random page. To do this, I created a table named a single column table named "Files" and populated it with the names of the aspx pages I have on the web server. Then I created a view over it with a SQL query

SELECT TOP(1) 'http://localhost/' + [dbo].[Files].[FileName] AS [PageName] FROM [dbo].[Files] ORDER BY NEWID()

Thanks to Philipe for giving this tip!

The above query will return a random page Url like http://localhost/Page1.aspx which is bound to a request in the WebTest.
Then I associated this WebTest with the LoadTest and configured the LoadTest to start with 1 user and add a new user every 1 second till a maximum count which will be equal to the number of pages on my web server. By selecting a distribution model based on the number of virtual users, I expected that the load test will result in user's getting a random unique page in each iteration. However, I was baffled to see what the load test engine was actually doing. On running the load test, the Page Results section in the Summary showed me that only one page was requested during the entire execution!!! On further investigation, I noticed that the WebLoadTestRequestMap table in the Load Test Database had only 1 RequestUri corresponding to my LoadTestRunId.

To get over this issue, I found it best to execute the above SQL statement using SqlDataReader in the WebTest code and create a WebTestRequest instance with the Url returned. With this approach, I am now able to successfully load test the scenario I had in mind. :)

Tuesday, September 30, 2008

WebTest brings down Visual Studio.

I started a WebTest that fires 200,000 requests to the web server. I left the test running overnight. On getting back to work today, I found that the Visual Studio instance running the test has crashed!! To my dismay, Visual Studio did not even generate a trx file, which would have given me some idea as to how many requests it was able to shoot and what might have caused it to crash.

This experience has made me wiser though. I have now kicked off the webtest using command line.

mstest /testcontainer:testproject2.dll /test:WebTest1Coded /runconfig:localtestrun.Testrunconfig /resultsfile:testResults.trx

The test has completed and I have a 639 MB trx file lying on my disk, which always brings down Visual Studio when I try to load it. So it is now as good as not having the file to analyze. Take this lesson from me (for free) - Do not try to run a WebTest that will generate a trx file of such a size that it cannot be opened later in VS for analysis. I could not find anything on msdn that tells me of the upper limit on size of trx file. Can we have that, Microsoft?

Instead of trying to find a fault with Microsoft, let me see what could have gone wrong in the code. The WebTest code was firing 200,000 requests in a for loop with each request getting a different aspx page. I think I should remove the for loop, parameterize the web page and create a load test based on this webtest. Let me check this. Will update this space in a few hours :)

Monday, September 29, 2008

ASP.NET SQLCacheDependency challenging scenarios

There is an ASP.NET application using VirtualPathProvider to return web pages from the database. The VPP uses SQL Server Query Notification (SQLCacheDependency) to get notified if pages change in the database. Hence for every web page request, an entry goes into the database registering w3wp.exe, which handles the page request, as a subsriber to page change notifications.

Lets assume that the application has handled 1 million requests in a day. So there are 1 million subscriptions in the DB registered against the process id of w3wp.exe (pid:1018). Now lets take a look at the list of scenarios which must be considered by the development team.
Case 1: Application pool recycled and then Page is changed in the DB
The subscriber process w3 with pid 1018 disappears. SQL Server will attempt to send a change notification but will fail and log the error message. User is very likely to see an older version of the page. Disk space utilization will increase.

Case 2: SQL Server recycled.
SQL Server will attempt to send out 1 million change notifications to the w3wp.exe process with pid 1018. Memory utilization of SQL Server will shoot up. Users may experience slow applications response.

Case 3: SQL Server and App pool recycled.
SQL Server will error out when trying to send out change notifications to the w3wp.exe process. Memory utilization of SQL Server & disk space utilization will shoot up. Users may experience slow applications response.

All 3 cases present an interesting engineering problem to solve! Will blog more about the possible solutions. Keep watching this space.

Friday, September 26, 2008

Selective proxy setting in WebTests

In developing a WebTest, I came across a scenario where I wanted a set of requests to use a proxy and another set of requests to bypass the proxy. A WebTest has a property named Proxy as shown in the figure below, which will be used by the Visual Studio Test Engine when sending out Http Requests.
In my WebTest, I wanted the 1st two WebRequests to bypass the proxy and the 3rd one to use a Proxy. Here I found it useful to create a WebTestRequestPlugin that is later associated with a WebRequest to set a proxy in the PreRequest method.


Here is the code for the WebTestRequestPlugin.

public class ProxySetter : WebTestRequestPlugin

{

    string proxy = null;

 

    public string Proxy

    {

        get

        {

            return this.proxy;

        }

        set

        {

            this.proxy = value;

        }

    }

 

    public override void PreRequest(object sender, PreRequestEventArgs e)

    {

        if (!String.IsNullOrEmpty(this.proxy))

        {

            e.WebTest.Proxy = this.proxy;

        }

        else

        {

            e.WebTest.Proxy = null;

        }

    }

}

Tuesday, July 1, 2008

Improving Website performance

While studying performance considerations for website design, I came across this site

http://developer.yahoo.com/performance/

that has good tips for developers to improve website performance.

What is success?

The journey of life takes us through varied experiences like landing an admission at a prestigious college, earning a degree, getting hired,...