Creating a customised 503 page in IIS 7 - asp.net

This is my first question :)
Is there any way to create a cutomised 503 error page in IIS7. Form what I have read, this error page is served up internally by http.sys and cannot be overriden. This is confirmed at the top of this page.
However, I have seen Questions on Stackoverflow where this is apparently possible, but I have had no luck trying to implement it. Could anyone give me a definitive answer?
Thanks in advance.

Sadly, the TechNet article is accurate - there is no way to replace 503 for the scenario you describe.
The error is detected by the IIS server as it attempts to hand the incoming request to your application. Everything your application does is performed in its app pool. Modules like rewrite rules and custom HTTP responses are all executed in this way.
If your application has no app pool to run in, it unavailable to do any custom processing: there is essentially no code running for your application.

Related

IIS - Unexplained 302 response code

What scenarios cause IIS to generate a 302 besides response.redirect? I'm working on an legacy ASP.NET app and it's generating 302s in IIS. The thing is, the code doesn't make any response.redirect calls. I don't know how to debug this thing. Could losing session generate a 302? I'm totally lost.
It can happen if you return a CSS file in ASP.NET over http when it should be over https, ive seen that happen in the past. Also if any web services tied into that application that are getting hit or making passes that fail, that could cause it too. Just shooting from my hip and trying to recall the last time I seen those issue's arise.
Check at the IIS level, not ASP.NET level.
Check the IIS management console. Possible options are:
"URL rewrite module"
"HTTP redirect" (under the website settings, for IIS7)

How to resolve Http 400 bad request Error in IIS 7?

We have migrated the our websites from one server to another server. all completed successfully but one website has issue of HTTP 400 bad request. I have googled alot but none of the solution works for me then I found this article which told me to set the website under the default website in. when i do that it works for me. but i want to make the previous one working. so please help me how can i do this and please let me know why it is working under default websites.
UPDATE: i have also enabled the log for tracing the error but its not creating a single log.
Thanks in advance.

URL Rewriting in Global.asax - IIS7

I have a fairly detailed problem with which I hope someone can help. Basically, I have a .NET 4.0 website hosted on IIS7 that has some pages that necessitate URL rewriting. In order to implement these features, I have added a method to my global.asax that maps the extension-less URLs to their proper ASPX pages, and then performs a context.RewritePath in order to display the correct page.
Initially, I called this method from application_BeginRequest. However, we have some business necessary logging that occurs when Session_Start is called, and it appears that this logging is not always happening since the implementation of the URL rewriting in application_BeginRequest - Basically, every session gets logged in the DB, and after initial deployment of the URL rewriting, our session logs have dropped by about 20%, with no corresponding errors in the application log. At the same time, our IIS logs seem to be showing a relatively unchanged amount of traffic, so to my eyes, it appears that the sessions are not instantiating properly.
As a workaround for this issue, I moved the URL rewriting from application_BeginRequest to application_AcquireRequestState, so that this code won't fire until after I'm (mostly) sure that the Session has started. This works in my local dev environment and on our staging server (Windows Server 2008 - IIS 7 - .NET 4.5 Framework installed). In the Production environment (Windows Server 2008 - IIS 7 - .NET 4.5 Framework), I get 404 errors when trying to browse to the extension-less URL to be re-written.
I'm completely stumped - I've verified that I'm using the Integrated app pool, my web.config has the "runAllManagedModulesForAllRequests=true" attribute, my IIS features include HTTP redirection and static file compression, but nothing appears to be working. There's a hack that I found for using the Classic app pool, and creating extra script map handlers to handle wildcard URLs with no extensions, but I'm hesitant to put that in place in production.
Any help you can provide would be greatly appreciated. Thank you!
I would concentrate on why there was a 20% drop in session logs. Are you sure there wasn't also a drop in traffic? Are you using redirects for people coming to your site using the old .aspx Urls? Perhaps you received more 404 traffic that would not trigger the Session_Start? Did Google Analytics confirm that traffic maintained normal levels after the UrlRewite was put into place? You could also use IIS Log Parser to filter out static files and query 200 vs 404s from the log files to get a better sense of actual traffic.

IIS 7.5 Logs and ASP.Net 404 Custom Pages

I want to make a custom 404 page for my site but I want to log all the normal information into my IIS 7.5 logs like the default 404 deals with so my Statics program can tell me things like what page got the 404 error, what was the referring URL to that broken page, and more. Do I have to do anything special on my 404 page to do this or has ASP evolved enough to automatically do logging for me if I return a 404 status code?
How you handle the errors determines how the errors will show up in the logs/responses. If you simply use custom error pages, it will show up no different in the log than if you had used the OOTB pages. If, however, you are writing an ASP.NET application, and handle/bury the exception, nothing will show up in the logs.
If you are writing a .NET application, this blog post provides a pretty good overview on how to properly handle errors for SEO.
ASP.NET Custom Error pages can be implemented in many different ways. The "worst" way are those that return a 301 redirection to "NotFound.aspx" (or similar), which will, of course, return a 200 status code. Unfortunately the IIS Manager actually lets you specify this method. If you're finding your 404s and 500s aren't being logged then check out this setting first.
Error pages, regardless of their implementation, must not issue any redirection and must set the status code to 404, that way IIS's logger will log it accordingly (IIS inspects the headers of all outgoing responses and uses that to populate the log).

HTTP Error 503 - But only when using domain name to navigate

I am currently having a strange issue that has taken me by surprise, I have not had the issue before and I have no idea why I am getting it now.
I have an asp.net mvc 3 website which has a number of controllers all with actions. It is important to note that this issue is only present with one controller and the problem is with all Actions.
The error I am getting is "HTTP Error 503. The service is unavailable."
However, this error only occurs if I browse to the page using the domain name, for example...
subdomain.example.com/controller
but everything works fine if I browse with the ip address and port number...
xxx.xxx.xxx.xxx:xxxxx/controller
remember all other controllers work fine regardless of the method used to browse.
I have tried looking for answers to this and trying to find any useful logging information but have found nothing of use. Hopefully somebody here will have seen this issue before
Ok I have created a sample mvc project with a Reports controller that works so I don't believe it is a problem with MVC.
I'd reccomend looking at your routes and your web.config and make sure you don't have anything intercepting it there into an httphandler or module. Then I'd look at the IIS instance and check for virtual directories. You pretty much are trying to figure out where exactly it is failing - is it even reaching ASP.Net?
One last option to look into is your company proxy - does going to the URL directly go through the proxy? I know at my company this can happen - so there may be a rule there that is intercepting it.

Resources