Saturday, March 28, 2009

Response.Header.Add doesn't work

I've tried to use:
Response.Header.Add("HeaderKeyName", "KeyValue")

But I got the following exception:
System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.
at System.Web.HttpResponse.get_Headers()

The work around:
Response.AddHeader("HeaderKeyName", "KeyValue")

For the least Microsoft could find a better exception description.

Tuesday, March 24, 2009

HyperLinkField not showing as link (ASP.NET)

After binding data to a HyperLinkField in a GridView it didn't show as link but as a normal text. Apparently when using navigation by data fields, the data in the fields set in DataNavigateUrlFields must be validated.

See some more information here:
http://stackoverflow.com/questions/640120/hyperlinkfield-not-showing-as-link

I had a problem when the field was a DateTime field returned by a database query. I've change the field format in the following way to make this work (navigation):
[Date] = convert(VARCHAR, [Date],104)

Tuesday, March 10, 2009

You are not authorized to view this page

Symptoms:

One clear morning, on an operational system (Windows 2003 x64, IIS, ASP.NET, SQL Server 2005) running an ASP.NET application, the users started to get request to fill their credentials, and after few times they got:
You are not authorized to view this page

With more specific notification:
HTTP Error 401.1 - Unauthorized: Access is denied due to invalid credentials.Internet Information Services (IIS)

In the event log of the server I found the following errors:
- System Events - I found warning event 1011 titled "W3SVC":
A process serving application pool 'DefaultAppPool' suffered a fatal communication error with the World Wide Web Publishing Service. The process id was '6756'. The data field contains the error number.

- Application Events - I found error event 1000 titled ".NET Runtime 2.0 Error Reporting":
Faulting application w3wp.exe, version 6.0.3790.3959, stamp 45d691cc, faulting module kernel32.dll, version 5.2.3790.4062, stamp 462643a7, debug? 0, fault address 0x0000000000027d8d.

Resolution:

I followed few wrong leads on the web, such as:

After wasting nearly a day a found the root cause:
The ASP.NET application had a stack-overflow bug.

From here fixing is easy.

The reason that I didn't suspected the ASP.NET application was that the stack-overflow bug was caused by a run time change of the data in the application, and not something new installed/configured.