Custom Error Page for Http Error 503 - asp.net

I need to send a Customized Error page for 503 Errors produced by my asp.net website. I have tried to simulate the condition by switching off the application pool (doesn't work) and by flooding my application with requests. Even though IIS sends me the default 503 error page, and even though I have tried setting a Custom URL in IIS and ASP.NET for this error code, it still returns me the default 503 error page !
I'd appreciate if someone could also tell me where the default 503 error page is kept that IIS sends.

Ran into the same problems, but I've just managed to get this working for us using a Classic ASP holding page in a .NET application (I'm not sure if it'll work the same for an apsx):
Make sure Classic ASP is enabled in IIS. Worth a read: http://blogs.iis.net/bills/archive/2007/05/21/tips-for-classic-asp-developers-on-iis7.aspx
Create a classic ASP file called Offline.asp and place it in the root of your website with the following contents:
<%
Response.Status = "503 Service Unavailable"
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex,nofollow" />
<title>Sorry, we're down for essential maintenance</title>
</head>
<body><h1>Sorry, we're down for essential maintenance</h1></body>
</html>
Now in IIS7 Manager go the Error Pages administration section, add a Custom Error Page like so:
Now whenever IIS receives a 503, it will send the contents of the Offline.asp to the browser, as well as the 503 code (which is important so that Search Engines don't list your error page!)
Now if you want to take your application offline you can just set up a simple redirect rule to redirect everything to Offline.asp.

You cannot customise the default 503 Service Unavailable error message. This is returned typically when the app pool is unavailable for some reason.
This description of when it occurs states that it comes directly from http.sys and everything on the internet seems to concur that it cannot be changed. I've looked at the http.sys registry settings and theres nothing useful there.
http://technet.microsoft.com/en-us/library/cc781893(WS.10).aspx

Take a look at HttpContext.Current.Response.TrySkipIisCustomErrors. just a suggestion.

As far as i can see, error pages are kept under %SystemDrive%\inetpub\custerr\<LANGUAGE-TAG>\<HTTP-CODE>.htm
You can configure custom error pages per website in your iis7 mmc.
edit
Apperently there is no way past http.sys in case of 503 - the only choice you get, is to send the default http 503 error message or to terminate the connection on tcp level.

Related

PageRequestManagerParserErrorException when changing Response during AJAX request

I get an exception after clicking on a button or performing somekind of ajax operation inside AjaxPanel.
SCRIPT5022: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
< !DOCTYPE html>.
Telerik.Web.UI.WebResource.axd, line 15 character 16238
On ASP.NET 4.0 with Telerik. This happens only on IE10. Meaning - works perfectly on chrome, Mozilla, previous IE.
I applied the hotfixes KB2600088 and KB2783767 on the server but still nothing. This is Windows Server 2003 Standard Edition 32-bit.
What can I do?
clicking on a button or
What can I do?
If you are modifying the HttpResponse state, it is necessary to move this "button"
from the Telerik AjaxPanel/MS UpdatePanel.
See the Sys.WebForms.PageRequestManagerParserErrorException - what it is and how to avoid it blog post for more information.
This problem is related to ajax request cycle and the problem solution is in webresources cache object is being treated by browser as unhandled request.
to resolve the problem the call trace must be captured using any web resource monitor and it is always advised to have request with timestamp or unique identifier.
unmannaged ajax requests under browser shows this type of error sometimes this also shows 500 error.
Thanks
I faced to this error few months ago when I migrate from IE 9 to IE 10.
It seems there is(are) an(some) incompatibility issue(s) between ASP.NET AJAX Client Library 4.x and IE 10.
I found changing compatibility settings of IE, would resolve my problem. I added following line:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
at top of my page as first line of html head section, before every other tags (as follow),
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=9" />
...
PageRequestManagerParserErrorException never occurred again, but some IE10 specific CSS3 rules did not affect because of changed compatibility setting.
I recently wrote this situation to Microsoft Connect and they told they are investigating.

ASP classic on IIS7.5 issue causes the response header to appear in the body

I have recently moved a classic ASP web application from IIS 6 to IIS 7.5 on Windows 2008 R2. This site has run great on IIS 6 for 4+ years. For the most part, the site works well on IIS 7.5, however, on occasion when you load a page something is happening where the response is not processed by the browser properly. As a result the actual response header is returned in the body of the response, either before the <html> tag or after the </html> tag. When the response is at the top before the <html> tag it is seen by the end user in the browser.
Sample response where the header is above the <html> tag:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 9714
Content-Type: text/html
Server: Microsoft-IIS/7.5
P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
Set-Cookie: CSB=UserType=3&Client=805157&FNAME=John+Doe&CAMS=False&Client%5FUser%5FMode=Online&Session=650680780&User=1&LastViewed=https%3A%2F%2Fsite%2Edomain%2Ecom%2Fcsb%2Fclient%2Fdefault%2Easp%3FClient%3D123456%26PBAT%3D654321%26BAT%3D654321&Username=jjd; path=/
X-Powered-By: ASP.NET
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<title>some page</title>
<script>...</script>
</head>
<body>
</body>
</html>
The content of the response header is literally rendered on the screen in the browser. This issue does not happen on every request. I've successfully reproduced the issue in IE and Chrome, but it's random so I have struggled being able to track down the root cause.
Sometimes the header is printed below the </html> tag and doesn't get rendered in the browser.
There are no errors thrown by IIS or ASP. I found this and I tried using the tracing failed request module in IIS and it didn't help because the request doesn't actually fail so there is nothing to trace.
I've tried watching the traffic in Fiddler, but all i get is the warning that the size of the response is larger than the header declares, which is because the actual response header text is being returned with the response body.
The server is running Windows Firewall and eset antivirus - but both were running on the old IIS 6 box as well.
In terms of configuring IIS, I've done all the basics that people recommend for running classic ASP.
I'm not a beginner when it comes to IIS configuration, but this is the only ASP site I really work with anymore and all I'm trying to do is to get it to run properly on the new setup.
I'm stuck, is there anyone out there that's seen this before?
This turned out to be an issue with an ISAPI filter that was introduced by a web application firewall we had installed that had a bug. Although we had tested with the ISAPI filter disabled, it turned out we had to completely remove the ISAPI in order to discover the issue. The vendor has since given us a patch to fix the bug. Thanks for the help!
Try this:
Response.Buffer=True
Let me know if it works for you...
for more info. on Response.Buffer see http://www.w3schools.com/asp/met_clear.asp
or try one of the codes below. (One by one to see if they work)
Response.Clear()
Response.ClearHeaders()
Response.Flush()
Response.End()
Response.AddHeader "Content-Length", "838100"
Good Luck...

Problem with PageRequestManagerParserErrorException with Ajax

I spent few hours today to try figure out the following error:
Sys.WebForms.PageRequestManagerParserErrorException: Object reference not set to an instance of an object
And note, I think my error is different the one below, so please don't confused with the error I am getting as this one:
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
I had tried different solution such as disable EventValidation, RoleManager cookie etc.
PartialRender=false on script maanger it gave me another error...
XhtmlConformation type="Tranitional" doesn't work... Context.ClearError() in Application Eror doesn't help...
And I got none of the Response.Write statement in my page, or things that describe in this page:
http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx
This error is happen when I postback the page and shown as a java script error in my IE.
During the postback, what my page does it only add/remove some controls that insides the AjaxPanel.
Every Ajax page is working fine on my development machine and few other web servers I had setup.
But today when I remote login to install my app for an office, the above error was occcured.
I tried to remove the code that does dynamically add/remove control during postback and it work fines.
But that part of coded is needed.
And is strange that working on every server but just not that one.
I wonder what can I do to do further debug? Since the error it only occurs in our customer's server(they need their server to work) it very hard for me to debug, all I can do now is just change some code that I think might solve it and upload to their server to test it.
Or what's the possible solution?
I faced to this error few months ago when I migrate from IE 9 to IE 10.
It seems there is(are) an(some) incompatibility issue(s) between ASP.NET AJAX Client Library 4.x and IE 10.
I found changing compatibility settings of IE, would resolve my problem.
I added following line:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
at top of my page as first line of html head section, before every other tags (as follow),
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=9" />
...
PageRequestManagerParserErrorException never occurred again, but some IE10 specific CSS3 rules did not affect because of changed compatibility setting.
I recently wrote this situation to Microsoft Connect and they told they are investigating.

Controller factory receiving request for "favicon.ico"

I've noticed that a request to "favicon.ico" is being passed to my ASP .NET MVC controller factory when using Google Chrome and the Visual Studio Development Server. The controllerType parameter has a value of null which is unsurprisingly resulting in an unhandled exception, which I only know about because of an error log.
Any ideas where the request is coming from and why ASP .NET is letting it get to the controller factory? CSS files and images for example are being correctly filtered out.
With IIS7 in integrated mode all requests are tunneled to the pipe. you can add it to your ignore routes
asp.net mvc does it handle all requests? - iis 7 integrated mode
Another resource
http://weblogs.asp.net/gunnarpeipman/archive/2009/02/26/asp-net-mvc-ignore-requests-to-favicon-ico.aspx
Bear in mind to you only seeing this as you are in debug mode. Your users wont see it (Not optimal still, but hey I didn't design it)
I have also noticed this occuring with chrome. I believe it is the browser looking for the site favicon (little icon next to its tab) with the default path of /favicon.ico. MVC trys to find a controller matching that route and comes up blank.
Easiest fix is probably just to add favicon image in your root directory called favicon.ico or using a link tag in the head section of your html to point it somewhere else.
eg
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />

Firefox 4 cannot load my ASP .Net site

I downloaded Firefox 4 yesterday and when I try to open my site (ASP .Net 2.0 site using masterpages) it tries to open the file rather than display the page. The message in the popup is: "You have chosen to open contactus.aspx which is a: aspx File from: 'my site'. What should Firefox do with this file?"
I am sending the following content-type: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> I also tried changing the charset to utf-8, same thing.
When I try to run the page through the w3 validator it gives me this message:
Warning Character Encoding mismatch!
The character encoding specified in the HTTP header (utf-8) is different from the value in the <meta> element (iso-8859-1). I will use the value from the HTTP header (utf-8) for this validation.
Is the server (IIS) somehow setting the default charset? Could this mismatch be the problem? What else can I look for? Also, one more thing, I have a mobile site running on the same server which uses "application/xhtml+xml; charset=utf-8" as the content-type and it works fine in FF4. Thanks!
Edit: here is an example page from the site: http://www.cvps.com/jobs.aspx
Edit 2: I think I have narrowed down the problem to the mobile detection. I am using 51 degrees mobile device detection from http://51degrees.codeplex.com/
Specifying the content type in a meta tag won't help - the browser needs to answer the question of what type it is before it looks at the contents of the file. You need to specify the content type in the server config.
Encoding can be usefully specified in the meta tag, but I'd still prefer to have it right in the server config.
The problem turned out to be with the mobile detection framework I am using (51degrees.mobi). I found a post on their support forums here that was similar to my problem and was able to fix the problem.

Resources