Rectangle 27 36

server {
    listen       80;
    server_name  localhost;

    location / {
        root   html;
        index  index.html index.htm;
    }

    error_page  404     /404.html;
    error_page  403     /403.html;

    # To allow POST on static pages
    error_page  405     =200 $uri;

    # ...
}

This is a hack, and you made no effort to explain it either.

It seems he's just rewriting the 405 to be a 200 - making it seem like it worked. It would be good to know if this does work. ie, will it return the static resource/

Wow, it works. But it's really indistinguishable from dirty hack.

I am using a wordpress plugin to post data to a different server and then return response. Some time it works fine, but in approx 95 % cases it failed and return " 405 method not allowed nginx" . where do i have to do this nginx.conf setting? do I have to install nginx on remote server and do this configuration? Please help I am facing almost similar problem but in a little different way.

node.js - POST request not allowed - 405 Not Allowed - nginx, even wit...

node.js express nginx cross-domain nodemailer
Rectangle 27 11

To start with, first set the customErrorss mode property to on. (This specifies that custom errors are enabled.)

<system.web>

    <customErrors mode="On"></customErrors>

</system.web>

Below is my controller code, I have specified the HandleError attribute on the controller class. Also to generate an error I am throwing an exception from the Index action.

[HandleError]
public class HomeController : Controller
{
    public ActionResult Index()
    {
    throw new Exception("Error Occured !");
    ViewBag.Message = "Welcome to ASP.NET MVC!";

    return View();
    }

    public ActionResult About()
    {
    return View();
    }
}

As you can see in the screenshot below, I have a Error.cshtml view defined inside the Shared folder of the Views folder.

Note that the Error.cshtml view (shown below) uses a model of System.Web.Mvc.HandleErrorInfo

@model System.Web.Mvc.HandleErrorInfo

@{
    ViewBag.Title = "Error";
}

<h2>
    Sorry, an error occurred while processing your request.
</h2>

On running the project, instead of getting the yellow death screen now I get the following output.

Try this out by creating a new project, this should and does work. I suspect that your Error.cshtml file may not have model as @model System.Web.Mvc.HandleErrorInfo or you may be having multiple Error.cshtml pages in different view folders.

Unfortunately, for me it still did not work. I've done as you told me. Furthermore, the HandleErrorAttribute is registered by default in global.asax so I usually don't need to set that Attribute for the Homecontroller.

@L4_ If it is still not working, see the answer about editing the right web.config - that's what was causing the issue in my case.

I'm glad I found this. I was going mad because 1) I was editing the wrong web.config, and 2) I didn't have the model as System.Web.Mvc.HandleErrorInfo. +1!

asp.net mvc - Custom Error Page does not show even though I set Custom...

asp.net-mvc error-handling web-config asp.net-mvc-4
Rectangle 27 5

One reason that could lead to what you are experiencing:

Something in your _layout is causing an exception to throw when the 'Error.cshtml' is rendering.

@{
    Layout = null;
}

in your 'Error.cshtml' file.

It's a pity I can only upvote once. Thanks.

asp.net mvc - Custom Error Page does not show even though I set Custom...

asp.net-mvc error-handling web-config asp.net-mvc-4
Rectangle 27 4

I fixed mine.. It's actually the *_Layout* page cannot be rendered because my _Layout.cshtml was strongly typed to a base view model which HandleErrorInfo can't be casted into. And you can never see this page binding error because it only happens when customError is on... that's just great.

asp.net mvc - Custom Error Page does not show even though I set Custom...

asp.net-mvc error-handling web-config asp.net-mvc-4
Rectangle 27 11

There's a lot of misinformation and/or out-of-date solutions regarding error handling in IIS 7+. The main things to understand are:-

  • IIS 7+ introduced a new way of handling custom error pages.

Most people are using hodge-podge solutions involving all of customErrors, httpErrors the Application_Error handler, and often setting requestValidationMode="2.0" on the httpRuntime property and/or disabling request validation entirely! This makes it really difficult to use other people's solutions because any and all of these can affect the behaviour. I had a quick search around and I found several semi-duplicates without accepted answers, probably for this reason.

The reason that these two errors give you different behaviour is that they occur at different stages in the request pipeline. The customErrors node in your web.config interacts with errors "inside" your application, while request validation takes place "outside" your application. IIS rejects the dangerous request before it gets to your application code, and so your customErrors replacement doesn't happen.

Ideally you want a solution with as few moving parts as possible. IIS7 gives us a new way to specify error page replacement at the IIS level instead of at the application level - the httpErrors node. This lets us catch all our errors in one place:-

<configuration>
  ...
  <system.webServer>
    ...
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <clear />
      <error statusCode="400" responseMode="ExecuteURL" path="/ServerError.aspx"/>
      <error statusCode="403" responseMode="ExecuteURL" path="/ServerError.aspx" />
      <error statusCode="404" responseMode="ExecuteURL" path="/PageNotFound.aspx" />
      <error statusCode="500" responseMode="ExecuteURL" path="/ServerError.aspx" />
    </httpErrors>
    ...
  </system.webServer>
  ...
</configuration>

If you care about SEO (and you should!), you still have to make sure that your controller/page sets an appropriate status code:-

this.Response.StatusCode = 500; // etc.

You should remove your customErrors node entirely. It is normally used for backwards-compatibility. You should also ensure that requestValidationMode is not set on the httpRuntime node.

This should catch most errors (excluding, obviously, errors in parsing your web.config!)

Note: in your case, if you want to set defaultPath on the httpErrors node, you'll get a lock violation because of ApplicationHost.config settings. You can either do as I did and just set path individually for the error codes you care about, or you can have a look at unlocking the node:-

My intuition is that it's more trouble than it's worth in low-control environments like Azure App Service / Azure Web Sites. You might as well set the paths for individual status codes.

By far this is the most detailed and perfect response that I've seen in years. Thank you very much!!! It's working perfectly!!!

I'm back with one more question: it seems that I have configured in my web.config a HttpModule (ImageProcessorModule) which intercepts all my calls (is quite normal) but when I'm dealing with the A potentially dangerous Request.RawUrl value was detected from the client, I see the error in clear text and no 500 custom error page shows up; though, if I'm commenting out this module to not intercept the requests, I see the custom error page... What am I missing? Why the system doesn't display the custom error message though the web.config says so?! Thank you very much!!!

You might be best posting that as a separate question with more info. I'm aware of cases where bugs in httpModules have caused problems with custom errors, but I'd need more to go on before I could narrow it down.

c# - ASP.NET MVC customError page doesn't get displayed for some of th...

c# asp.net asp.net-mvc
Rectangle 27 1

UPD: Ok, after reviewing the question I realised that the problem is in something else.. By default the authentication system in ASP.NET redirects all 403 requests to the login page. This is the way it's coded, and yes, it ignores the we.config settings.

There are solutions, of course.. You can check an example of how it was solved here ( similar question of SO ) With ASP.NET membership, how can I show a 403?

asp.net - CustomError not working properly - Stack Overflow

asp.net visual-studio-2008 web-config
Rectangle 27 1

I had the same problem when I was updating the wrong web.config file.

There is a web.config in the Views folder and also under the project application site.

The solution would be to update web.config located under project.

Sorry for my late answer ;) but I already had updated the right web.config as you mentioned. Anyway the problem still persists.

I am on MVC3 and just added the below settings to web.config and custom page and it works for me. <customErrors mode="On" defaultRedirect="~/Views/Shared/Error.cshtml"> <error redirect="~/Home/NotFound" statusCode="404" /> '</customErrors>

asp.net mvc - Custom Error Page does not show even though I set Custom...

asp.net-mvc error-handling web-config asp.net-mvc-4
Rectangle 27 11

There's a lot of misinformation and/or out-of-date solutions regarding error handling in IIS 7+. The main things to understand are:-

  • IIS 7+ introduced a new way of handling custom error pages.

Most people are using hodge-podge solutions involving all of customErrors, httpErrors the Application_Error handler, and often setting requestValidationMode="2.0" on the httpRuntime property and/or disabling request validation entirely! This makes it really difficult to use other people's solutions because any and all of these can affect the behaviour. I had a quick search around and I found several semi-duplicates without accepted answers, probably for this reason.

The reason that these two errors give you different behaviour is that they occur at different stages in the request pipeline. The customErrors node in your web.config interacts with errors "inside" your application, while request validation takes place "outside" your application. IIS rejects the dangerous request before it gets to your application code, and so your customErrors replacement doesn't happen.

Ideally you want a solution with as few moving parts as possible. IIS7 gives us a new way to specify error page replacement at the IIS level instead of at the application level - the httpErrors node. This lets us catch all our errors in one place:-

<configuration>
  ...
  <system.webServer>
    ...
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <clear />
      <error statusCode="400" responseMode="ExecuteURL" path="/ServerError.aspx"/>
      <error statusCode="403" responseMode="ExecuteURL" path="/ServerError.aspx" />
      <error statusCode="404" responseMode="ExecuteURL" path="/PageNotFound.aspx" />
      <error statusCode="500" responseMode="ExecuteURL" path="/ServerError.aspx" />
    </httpErrors>
    ...
  </system.webServer>
  ...
</configuration>

If you care about SEO (and you should!), you still have to make sure that your controller/page sets an appropriate status code:-

this.Response.StatusCode = 500; // etc.

You should remove your customErrors node entirely. It is normally used for backwards-compatibility. You should also ensure that requestValidationMode is not set on the httpRuntime node.

This should catch most errors (excluding, obviously, errors in parsing your web.config!)

Note: in your case, if you want to set defaultPath on the httpErrors node, you'll get a lock violation because of ApplicationHost.config settings. You can either do as I did and just set path individually for the error codes you care about, or you can have a look at unlocking the node:-

My intuition is that it's more trouble than it's worth in low-control environments like Azure App Service / Azure Web Sites. You might as well set the paths for individual status codes.

By far this is the most detailed and perfect response that I've seen in years. Thank you very much!!! It's working perfectly!!!

I'm back with one more question: it seems that I have configured in my web.config a HttpModule (ImageProcessorModule) which intercepts all my calls (is quite normal) but when I'm dealing with the A potentially dangerous Request.RawUrl value was detected from the client, I see the error in clear text and no 500 custom error page shows up; though, if I'm commenting out this module to not intercept the requests, I see the custom error page... What am I missing? Why the system doesn't display the custom error message though the web.config says so?! Thank you very much!!!

You might be best posting that as a separate question with more info. I'm aware of cases where bugs in httpModules have caused problems with custom errors, but I'd need more to go on before I could narrow it down.

c# - ASP.NET MVC customError page doesn't get displayed for some of th...

c# asp.net asp.net-mvc
Rectangle 27 10

There's a lot of misinformation and/or out-of-date solutions regarding error handling in IIS 7+. The main things to understand are:-

  • IIS 7+ introduced a new way of handling custom error pages.

Most people are using hodge-podge solutions involving all of customErrors, httpErrors the Application_Error handler, and often setting requestValidationMode="2.0" on the httpRuntime property and/or disabling request validation entirely! This makes it really difficult to use other people's solutions because any and all of these can affect the behaviour. I had a quick search around and I found several semi-duplicates without accepted answers, probably for this reason.

The reason that these two errors give you different behaviour is that they occur at different stages in the request pipeline. The customErrors node in your web.config interacts with errors "inside" your application, while request validation takes place "outside" your application. IIS rejects the dangerous request before it gets to your application code, and so your customErrors replacement doesn't happen.

Ideally you want a solution with as few moving parts as possible. IIS7 gives us a new way to specify error page replacement at the IIS level instead of at the application level - the httpErrors node. This lets us catch all our errors in one place:-

<configuration>
  ...
  <system.webServer>
    ...
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <clear />
      <error statusCode="400" responseMode="ExecuteURL" path="/ServerError.aspx"/>
      <error statusCode="403" responseMode="ExecuteURL" path="/ServerError.aspx" />
      <error statusCode="404" responseMode="ExecuteURL" path="/PageNotFound.aspx" />
      <error statusCode="500" responseMode="ExecuteURL" path="/ServerError.aspx" />
    </httpErrors>
    ...
  </system.webServer>
  ...
</configuration>

If you care about SEO (and you should!), you still have to make sure that your controller/page sets an appropriate status code:-

this.Response.StatusCode = 500; // etc.

You should remove your customErrors node entirely. It is normally used for backwards-compatibility. You should also ensure that requestValidationMode is not set on the httpRuntime node.

This should catch most errors (excluding, obviously, errors in parsing your web.config!)

Note: in your case, if you want to set defaultPath on the httpErrors node, you'll get a lock violation because of ApplicationHost.config settings. You can either do as I did and just set path individually for the error codes you care about, or you can have a look at unlocking the node:-

My intuition is that it's more trouble than it's worth in low-control environments like Azure App Service / Azure Web Sites. You might as well set the paths for individual status codes.

By far this is the most detailed and perfect response that I've seen in years. Thank you very much!!! It's working perfectly!!!

I'm back with one more question: it seems that I have configured in my web.config a HttpModule (ImageProcessorModule) which intercepts all my calls (is quite normal) but when I'm dealing with the A potentially dangerous Request.RawUrl value was detected from the client, I see the error in clear text and no 500 custom error page shows up; though, if I'm commenting out this module to not intercept the requests, I see the custom error page... What am I missing? Why the system doesn't display the custom error message though the web.config says so?! Thank you very much!!!

You might be best posting that as a separate question with more info. I'm aware of cases where bugs in httpModules have caused problems with custom errors, but I'd need more to go on before I could narrow it down.

c# - ASP.NET MVC customError page doesn't get displayed for some of th...

c# asp.net asp.net-mvc
Rectangle 27 153

@RestController
public class IndexController implements ErrorController{

    private static final String PATH = "/error";

    @RequestMapping(value = PATH)
    public String error() {
        return "Error handling";
    }

    @Override
    public String getErrorPath() {
        return PATH;
    }
}

Your code did not work, because Spring Boot automatically registers the BasicErrorController as a Spring Bean when you have not specified an implementation of ErrorController.

ErrorMvcAutoConfiguration.basicErrorController

Ran into the same into the same issue, I searched the Spring docs but it didn't mention BasicErrorController. This works :)

Thanks, worked nicely! A small follow-up if you can give any pointers: say we get in this error handler because some exception was thrown in our app (and Spring implicitly sets response code to 500 which is correct); is there an easy way to get hold of that exception here (to include some details in error message returned)?

Hmm, yes, thanks again! At first I wasn't sure how to get that ErrorAttributes object (containing the error details), but then I tried simply @Autowiring it, and it works. What I went with for now: gist.github.com/jonikarppinen/662c38fb57a23de61c8b

Spring Boot Remove Whitelabel Error Page - Stack Overflow

spring spring-boot
Rectangle 27 145

Facelets is a XML based view technology. XML has only five predefined entities. The is not among them. It works only when used in plain HTML or in legacy JSP (note: it doesn't work in JSPX as that's also XML based!).

To fix this, you either need to declare the entity yourself in the doctype,

<!DOCTYPE html [
    <!ENTITY nbsp "&#160;"> 
]>

or to use the (hexa)decimal notation instead:

&#xA0; or &#160;

Use the hex or decimal notation. :-)

jsf - Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nb...

jsf jsf-2 facelets html-entities
Rectangle 27 145

Facelets is a XML based view technology. XML has only five predefined entities. The is not among them. It works only when used in plain HTML or in legacy JSP (note: it doesn't work in JSPX as that's also XML based!).

To fix this, you either need to declare the entity yourself in the doctype,

<!DOCTYPE html [
    <!ENTITY nbsp "&#160;"> 
]>

or to use the (hexa)decimal notation instead:

&#xA0; or &#160;

Use the hex or decimal notation. :-)

jsf - Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nb...

jsf jsf-2 facelets html-entities
Rectangle 27 51

Under your main views.py add your own custom implementation of the following two views, and just set up the templates 404.html and 500.html with what you want to display.

urls.py
from django.shortcuts import render_to_response
from django.template import RequestContext


def handler404(request):
    response = render_to_response('404.html', {},
                                  context_instance=RequestContext(request))
    response.status_code = 404
    return response


def handler500(request):
    response = render_to_response('500.html', {},
                                  context_instance=RequestContext(request))
    response.status_code = 500
    return response

handler404 and handler500 are exported Django string configuration variables found in django/conf/urls/__init__.py. That is why the above config works.

To get the above config to work, you should define these variables in your urls.py file and point the exported Django variables to the string Python path of where these Django functional views are defined, like so:

# project/urls.py

handler404 = 'my_app.views.handler404'
handler500 = 'my_app.views.handler500'

If you use views as above, handler404 will fail with message:

def handler404(request, exception, template_name='404.html'):
    ...

This seemed to work quite well for me, but for some reason request.user appears fine in the 404 template, but not at all in the 500 template (and they are almost identical) -- posted question on this here: stackoverflow.com/questions/26043211/

Another thing I was wondering about -- what if you use the admin backend and want to use separate templates for those? To my knowledge, admin doesn't have a views.py to override and put this bit of code in.

@GravityGrave the 500 template won't render request.user because it is reporting a 500 server error, so the server is not able to serve up anything.

Didn't work for me with django 1.9 ;( Maybe I'm doing something wrong. Is handler404 django reserved name? How would django know that it should call exactly that view?

I updated the answer based on your comment. Sorry that the update is so late. I hope that this helps.

python - Django, creating a custom 500/404 error page - Stack Overflow

python django django-templates http-status-code-404
Rectangle 27 35

public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
}
public void Application_Error(Object sender, EventArgs e)
{
    Exception exception = Server.GetLastError();
    Server.ClearError();

    var routeData = new RouteData();
    routeData.Values.Add("controller", "ErrorPage");
    routeData.Values.Add("action", "Error");
    routeData.Values.Add("exception", exception);

    if (exception.GetType() == typeof(HttpException))
    {
        routeData.Values.Add("statusCode", ((HttpException)exception).GetHttpCode());
    }
    else
    {
        routeData.Values.Add("statusCode", 500);
    }

    Response.TrySkipIisCustomErrors = true;
    IController controller = new ErrorPageController();
    controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
    Response.End();
}
public class ErrorPageController : Controller
{
    public ActionResult Error(int statusCode, Exception exception)
    {
         Response.StatusCode = statusCode;
         ViewBag.StatusCode = statusCode + " Error";
         return View();
    }
}

[5]: in 'Views/Shared/Error.cshtml'

@model System.Web.Mvc.HandleErrorInfo
@{
    ViewBag.Title = (!String.IsNullOrEmpty(ViewBag.StatusCode)) ? ViewBag.StatusCode : "500 Error";
}

<h1 class="error">@(!String.IsNullOrEmpty(ViewBag.StatusCode) ? ViewBag.StatusCode : "500 Error"):</h1>

//@Model.ActionName
//@Model.ControllerName
//@Model.Exception.Message
//@Model.Exception.StackTrace

just tried to implement this. accessing a non existing page returns nothing. (instead of 404)

Just to make it clear, it return a 404 status code, with a blank page.

@Dementic: Yes it's a blank page so you can customise it. I have it working OK on a few sites now.

Does your solution work properly with AJAX requests? Also, you clear the server error before you recognize that it was an HttpException error.

ASP.NET MVC 5 Custom Error Page - Stack Overflow

asp.net-mvc custom-error-pages custom-errors
Rectangle 27 34

Here is the link to the official documentation on how to set up custom error views:

It says to add lines like these in your URLconf (setting them anywhere else will have no effect):

handler404 = 'mysite.views.my_custom_page_not_found_view'
handler500 = 'mysite.views.my_custom_error_view'
handler403 = 'mysite.views.my_custom_permission_denied_view'
handler400 = 'mysite.views.my_custom_bad_request_view'

You can also customise the CSRF error view by modifying the setting CSRF_FAILURE_VIEW.

It's worth reading the documentation of the default error handlers, page_not_found, server_error, permission_denied and bad_request. By default, they use these templates if they can find them, respectively: 404.html, 500.html, 403.html, and 400.html.

So if all you want to do is make pretty error pages, just create those files in a TEMPLATE_DIRS directory, you don't need to edit URLConf at all. Read the documentation to see which context variables are available.

In Django 1.10 and later, the default CSRF error view uses the template 403_csrf.html.

DEBUG

I did add, but it doesn't work. Added the handler404 and others pointing to right places in my views, yet it doesn't work, still seeing the default 404. And yes, I'm in Debug False mode and using 1.9

Using Django 1.9 and simply adding 500.html etc templates shows them instead of standard pages. Nice easy fix.

Gotcha helped me. It worked by making these changes in my settings.py, set DEBUG=False and ALLOWED_HOSTS = ['0.0.0.0'] to accept http request from any client.

python - Django, creating a custom 500/404 error page - Stack Overflow

python django django-templates http-status-code-404
Rectangle 27 34

public class FilterConfig
{
    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }
}
public void Application_Error(Object sender, EventArgs e)
{
    Exception exception = Server.GetLastError();
    Server.ClearError();

    var routeData = new RouteData();
    routeData.Values.Add("controller", "ErrorPage");
    routeData.Values.Add("action", "Error");
    routeData.Values.Add("exception", exception);

    if (exception.GetType() == typeof(HttpException))
    {
        routeData.Values.Add("statusCode", ((HttpException)exception).GetHttpCode());
    }
    else
    {
        routeData.Values.Add("statusCode", 500);
    }

    Response.TrySkipIisCustomErrors = true;
    IController controller = new ErrorPageController();
    controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
    Response.End();
}
public class ErrorPageController : Controller
{
    public ActionResult Error(int statusCode, Exception exception)
    {
         Response.StatusCode = statusCode;
         ViewBag.StatusCode = statusCode + " Error";
         return View();
    }
}

[5]: in 'Views/Shared/Error.cshtml'

@model System.Web.Mvc.HandleErrorInfo
@{
    ViewBag.Title = (!String.IsNullOrEmpty(ViewBag.StatusCode)) ? ViewBag.StatusCode : "500 Error";
}

<h1 class="error">@(!String.IsNullOrEmpty(ViewBag.StatusCode) ? ViewBag.StatusCode : "500 Error"):</h1>

//@Model.ActionName
//@Model.ControllerName
//@Model.Exception.Message
//@Model.Exception.StackTrace

just tried to implement this. accessing a non existing page returns nothing. (instead of 404)

Just to make it clear, it return a 404 status code, with a blank page.

@Dementic: Yes it's a blank page so you can customise it. I have it working OK on a few sites now.

Does your solution work properly with AJAX requests? Also, you clear the server error before you recognize that it was an HttpException error.

ASP.NET MVC 5 Custom Error Page - Stack Overflow

asp.net-mvc custom-error-pages custom-errors
Rectangle 27 34

If you want a more "JSONish" response page you can try something like that:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/error")
public class SimpleErrorController implements ErrorController {

  private final ErrorAttributes errorAttributes;

  @Autowired
  public SimpleErrorController(ErrorAttributes errorAttributes) {
    Assert.notNull(errorAttributes, "ErrorAttributes must not be null");
    this.errorAttributes = errorAttributes;
  }

  @Override
  public String getErrorPath() {
    return "/error";
  }

  @RequestMapping
  public Map<String, Object> error(HttpServletRequest aRequest){
     Map<String, Object> body = getErrorAttributes(aRequest,getTraceParameter(aRequest));
     String trace = (String) body.get("trace");
     if(trace != null){
       String[] lines = trace.split("\n\t");
       body.put("trace", lines);
     }
     return body;
  }

  private boolean getTraceParameter(HttpServletRequest request) {
    String parameter = request.getParameter("trace");
    if (parameter == null) {
        return false;
    }
    return !"false".equals(parameter.toLowerCase());
  }

  private Map<String, Object> getErrorAttributes(HttpServletRequest aRequest, boolean includeStackTrace) {
    RequestAttributes requestAttributes = new ServletRequestAttributes(aRequest);
    return errorAttributes.getErrorAttributes(requestAttributes, includeStackTrace);
  }
}

Spring Boot Remove Whitelabel Error Page - Stack Overflow

spring spring-boot
Rectangle 27 11

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):

  • 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.

I have just achieved the same thing with an aspx file. I put the server side code in the aspx file to keep things simple.

This doesn't work when the app pool is stopped either. I'm not sure if it would work if the app pool was overloaded as it is hard to recreate that condition when you want it.

asp.net - Custom Error Page for Http Error 503 - Stack Overflow

asp.net iis-7 http-status-code-503
Rectangle 27 32

Install the gd library also.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

php - Fatal error: Call to undefined function mb_detect_encoding() - S...

php mbstring
Rectangle 27 26

There's a much easier way than recompiling PHP. Just yum install the required mbstring library:

yum --enablerepo=remi install php-mbstring

This also worked in openSuse 13.1 after getting a white homepage for phpMyAdmin: ` yast -i php-mbstring `

If you have multiple versions installed on your system, you may need to install the version-specific library, e.g. with sudo apt install php5.6-mbstring.

php - Fatal error: Call to undefined function mb_detect_encoding() - S...

php mbstring