ASP.NET 4.0 Custom Error Pages Very Slow to Load

When I upgraded to ASP.NET 4.0, runtime errors suddenly became very slow. There was a consistent two-minute delay before my custom error page would appear. The rest of the website was lightning fast, so it was not related to compilation. I finally decided to tackle this problem, so I started copying blocks of code into a new, blank custom error page. The delay was not present until I copied this line of code:

Response.StatusCode = 500

I had been searching the web for terms like "asp.net error page very slow" with no success. One quick search on "asp.net statuscode slow" finally returned some helpful results:

http://stackoverflow.com/questions/3288797/page-not-rendered-when-sending-statuscode-500-to-the-client

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.tryskipiiscustomerrors.aspx

http://www.west-wind.com/weblog/posts/2009/Apr/29/IIS-7-Error-Pages-taking-over-500-Errors

All I had to do was drop in one line of code where I set the status code.

Response.TrySkipIisCustomErrors = True

The delay is gone now, but I still have no idea what's going on inside the black box.

Remote Desktop Services Multiple Sessions

As far as I can tell, it is trivial to enable multiple simultaneous remote desktop sessions for Windows Server 2008.

  • Open gpedit.msc
  • Navigate to Computer Configuration -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Connections
  • Double-click “Restrict Remote Desktop Services users to a single Remote Desktop Services session
  • Check “Disabled” and apply.

There is one caveat, however. It seems to leave a Console session active at all times. You can log off the Console session via Task Manager. If you connect to it (by right-clicking it in task manager) it doesn’t seem to be doing anything.

How to display ASP errors on Windows 2008 II7

By default ASP errors are not displayed on a Windows 2008, II7 server. The default error message displayed simply says:

Server Error
500 – Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

This is for very good reason. Detailed error message can display sensitive information that you do not want public. But for development purposes we need to see the error message to properly resolve the error. Here are the steps to display the detailed error message.

In the IIS settings for the website:

1. Go to “ASP” (under IIS).

2. Set “Send Errors to Browser” to true.

If it still doesn’t display the detailed error follow these steps.

1. Go to “Configuration Editor” (under Management section).

2. Under system.webServer, select “httpErrors”.

3. Set errorMode to “Detailed”

Be sure to add proper error handling when taking the website live.

SQL Server 2005 SSIS Packages

Today I used SSIS packages for the first time. SSIS packages are used by SQL Server Integration Services. There are a couple things I have found about SSIS packages that I want to write about.

I am using an SSIS package to copy data from an Access database to SQL Server. This SSIS package can be executed on a schedule, or from a web browser. I couldn’t figure out how to execute an SSIS package, so I found some excellent instructions on this blog.

  1. I believe you can only run SSIS packages on SQL Server 2005. SQL Server Integration Services doesn’t come with SQL Server Express. 
     
  2. In order to run my SSIS package, I needed to have xp_cmdshell enabled in SQL Server Surface Area Configuration.
     
  3. I can execute the stored procedure from VB or CS code in ASP.Net, but it is more secure to hard-code the command line in a Stored Procedure and call that from the VB or CS code.
     
  4. The command line I use is:

    Declare @SSISPackage varchar(50)
    exec
    master..xp_cmdshell ‘dtexec /F “‘ + @SSISPackage + ‘”‘

  5. To run this stored procedure, the user must have access to the mssqlsystemresource database. Thus, as far as I know, you have to log in with the sa account. I use the sa account only on this one page that needs it. Everywhere else on this site cannot access the sa account. If you don’t have privileges, you will get this message:
    The EXECUTE permission was denied on the object ‘xp_cmdshell’, database ‘mssqlsystemresource’, schema ‘sys’.

These are just my notes for SQL Server Integration Services. SSIS allows me to easily perform this import process very easily.

Zachary Lyons

Server.ScriptTimeout Not Working

I had a file upload page that gave an HttpException with message “Request timed out”. Natrually, I set the Server.ScriptTimeout to 360. But I still got the error rmessage. To solve this I added the following to the web.config file:

<httpRuntime
executionTimeout=360
maxRequestLength=41000 />

The maxRequestLength did not solve the problem by itself. The executionTimeout was needed as well.