iis custom error page not working - c#

I create a error page in iis for 503 error. Now i stop my website application pool. i got the other page service unavailable not my custom error page. I also try to config in web.config. It's not working please help me..
tried 1
<httpErrors errorMode="Custom">
<remove statusCode="503" subStatusCode="-1" />
<error statusCode="503" prefixLanguageFilePath="" path="/503.htm"
responseMode="ExecuteURL" />
</httpErrors>
tried 2
<customErrors mode="On">
<error statusCode="503" redirect="~/503.htm"/>
</customErrors>

if the site is stopped this means no instance is listening to requests to this site. thus it is not possible to do so by web.config.
If what you mean is to use a custom page for site maintenance, you can take use of the app_offline.htm file:
Taking an ASP.NET Site Offline with a Message
http://weblogs.asp.net/pleloup/archive/2008/09/22/taking-an-asp-net-site-offline-with-a-message.aspx

Related

intranet windows authentication with with custom login page in ASP.NET MVC

We have ASP.NET MVC application with intra and internet user(Windows authentication). if user open application within intranet, need to auto login. Else need to show custom login page where we will manually authenticate. (Currently it show 401 prompt due to ntlm negotiate).
Is there a way to show custom login page on ntlm 401. we tried iis error page, application_endrequest and webconfig(error page). Nothing works out.
In Asp.Net MVC you can create custom Error Pages with your own defined html layout in web.config like this:
<!--IIS Custom Errors-->
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="/CustomErrors/404.html" responseMode="ExecuteURL" />
<remove statusCode="500" />
<error statusCode="500" path="/CustomErrors/500.html" responseMode="ExecuteURL" />
</httpErrors>

Custom error page is not displaying on IIS7 ASP.NET

I want to add custom error pages to my site. Firstly I have created a test web project, added two test pages, publish it to my local IIS and configured the web.config:
<configuration>
<system.web>
<compilation targetFramework="4.0" />
<customErrors mode="On" defaultRedirect="http://localhost:10000/apperror.aspx">
<error statusCode="404" redirect="http://localhost:10000/404.aspx" />
</customErrors>
</system.web>
I can browse this pages separately but when I try to access a not found page like:
http://localhost:10000/notfound.aspx
It works perfect and redirects to my error page. But when I try below
http://localhost:10000/notfound
IIS is showing his own error page not my custom error pages. I have searched but not found a solution, Could you please help me how can I achieve this?
Be sure you've selected "Custom Error Pages" in Error Page settings in IIS.
Login to IIS web server.
Expand the sites and select your website name.
From the Feature view, Under IIS section select the Error Pages.
Select the 404 error and right click on it.
Select the "Edit Feature Settings".
Select "Custom Error Pages" and click OK to save the settings.
I always use this approach. First, remove the error handling from system.web, then add this:
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace">
<remove statusCode="404" />
<remove statusCode="500" />
<error statusCode="404" responseMode="ExecuteURL" path="/Errors/NotFound" />
<error statusCode="500" responseMode="ExecuteURL" path="/Errors/InternalError" />
</httpErrors>
</system.webServer>

IIS display standard yellow page instead of custom error page defined

I have defined custom error pages in IIS (i.e for http status code 500) and they are working if I return status code 500 from controller. But if there is unhandled exception in application iis displays standard yellow page with status code 500. So I'd expect IIS to display my custom error page but it's not happening.
Is there any way to force IIS to display custom error page on exception?
You should add this into the web.config into <system.web> section:
<customErrors mode="On" defaultRedirect="~/path/to/error">
<error statusCode="413" redirect="~/path/to/error" />
...
...
</customErrors>
My advice is to do this only for the production environment, because the "yellow page" is extremely useful in dev mode to identity errors (for example you can add it only into web.release.config).
Inside <system.webServer> add
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" subStatusCode="-1" prefixLanguageFilePath="" path="/somePage.html" responseMode="Redirect" />
</httpErrors>

How to config IIS to redirect to custom error page when accessing unsupported extension

I've tried some ways to deploy my custom error page (e.g. error.aspx) onto my website:
Added customErrors: <customErrors mode="On"
defaultRedirect="error.aspx" />
Added httpError: <httpErrors>
<remove statusCode="404" subStatusCode="-1" /> <error
statusCode="404" prefixLanguageFilePath="" path="error.aspx"
responseMode="ExecuteURL" /> </httpErrors>
Currently, I can point this URL to my custom error page:
http://test.localdev.net/random_text.aspx
However, I failed for those kind of URL (unsupported extension), for these URLs IIS will use its own 404 page:
http://test.localdev.net/Default.random
Could anyone help me to fix it?
Thanks
are you using iis7 or later in integrated mode? Otherwise I think you need to configure error pages in iis itself.

ASP.NET 3.5 C# custom error pages in webforms application

I'm working on a personal website and I'm using webforms and .NET 3.5 and C#. I'm trying to get the custom error pages sorted but I can't get them to work properly. Not on my local IIS 7.5 as on the external server. It keeps prompting me with default IIS error pages when pages can't be found. How can it be fixed?
I've got the following section in my web.config file defining the errorpages;
<customErrors mode="RemoteOnly" defaultRedirect="~/ERRORPAGES/Default.aspx" redirectMode="ResponseRewrite">
<error statusCode="403" redirect="~/ERRORPAGES/Default.aspx" />
<error statusCode="404" redirect="~/ERRORPAGES/404.aspx" />
<error statusCode="400" redirect="~/ERRORPAGES/400.aspx" />
<error statusCode="500" redirect="~/ERRORPAGES/500.aspx" />
</customErrors>
Found out there was a problem with the server i was running. The host changed it and now online everything works as i expected it to be.

Categories

Resources