custom-errors

ASP.NET MVC 5 Custom Error Page

走远了吗. 提交于 2019-11-28 17:02:56
I am using a custom authorize attribute in a ASP.NET MVC 5 application like following: public class CustomAuthorizeAttribute : AuthorizeAttribute { protected override void HandleUnauthorizedRequest(AuthorizationContext context) { if (context.HttpContext.Request.IsAuthenticated) { context.Result = new System.Web.Mvc.HttpStatusCodeResult((int)System.Net.HttpStatusCode.Forbidden); } else { base.HandleUnauthorizedRequest(context); } } } In system.web section of my web.config I mentioned error paths like: <system.web> <customErrors mode="On" defaultRedirect="/Error/Error"> <error statusCode="403"

How does one write good error messages?

别等时光非礼了梦想. 提交于 2019-11-28 16:12:20
While this is more of a written language issue than a coding one, it is something that programmers must do in circumstances where copy is not provided by a client or someone else. Any examples of error messages, good or bad, are welcome to make the point. I briefly searched and could not find a dupe thread. Ok, have at it. Thanks, all. Apologise. Say what went wrong. Say how to resolve it. Be polite. The message should be worded so that the application accepts responsibility for the problem. Never blame or criticize the user or make them think it's their fault. Example: "Sorry, the file could

ASP.NET/IIS: 404 for all file types

别来无恙 提交于 2019-11-28 08:40:00
问题 I set up 404 handler page in web.config, but it works ONLY when extension of URL is .aspx (or other which is handled by ASP.NET). I know I can setup static HTML page in website options, but I want to have a page. Is there any options to assign ASPX handler page for all request extensions in IIS? 回答1: The direct question was whether or not there are options to assign the ASPX handler to all request extensions: Yes, there is. I'll discuss how to do that shortly. First, I think the "hidden"

Why is HttpContext.Session null when redirectMode = ResponseRewrite

眉间皱痕 提交于 2019-11-28 07:18:41
问题 As is suggested elsewhere, I am using redirectMode = ResponseRewrite in my custom error configuration so my custom error page can access the exception info. This has worked like a charm for some time. In adding some more "help the user recover from an error" type functionality, we need a piece of info that has been previously stored in Session. When implementing this, I found that the various avenues to Session end in null when redirectMode=ResponseRewrite, but they are all populated when

How do I catch the http status code of server errors into a generic custom error view in ASP.NET MVC

穿精又带淫゛_ 提交于 2019-11-28 05:43:28
问题 I am trying to implement a general custom error page in ASP.NET MVC 4. I basically set up an Error Layout, which defines a section for outputting the http status code of the response. The view that I want my errors to end up at inherits such layout, and simply adds a message that comes from its model, which was instantiated and passed in the call to View() in the Controller (named "Error") I set up to handle custom errors, in the web.config. <customErrors defaultRedirect="/Error" mode="On"> <

customerrors for 401.2 in ASP.NET

喜欢而已 提交于 2019-11-28 03:16:03
问题 I successfully implemented role based authorization in ASP.NET. When a person does not have the needed role he gets to see an error page for 401.2 not authorized. What I would like to accomplish now is to have a custom 401 page in my application and have it redirected there via settings in the web.config. I tried this: <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="401" redirect="NoAccess.htm" /> </customErrors> But this does not get caught. Do I

How do I create a custom validator with a custom error message in Grails?

别等时光非礼了梦想. 提交于 2019-11-27 19:47:50
How do I create a custom validator in grails and make it pass a custom string back to the view and an error message? I saw so many people getting stuck in the same please, I decided to create a question and an answer to deal with it. Step 1: Create a Domain Object or Command Object and put custom constrains on it, as such... @grails.validation.Validateable class PeopleCommand { String firstName String lastName String emailAddress String idNumber static constraints = { firstName (blank: false) lastName (blank: false) emailAddress (blank: false) idNumber (blank: false, size: 13..16, validator:

Asp.net - <customErrors mode=“Off”/> error when trying to access working webpage

前提是你 提交于 2019-11-27 18:48:32
I have created an asp.net webpage and have uploaded it onto a webserver. However when I try to view the page remotely, I get errors about the customerror tag in the web.config file. The page works locally with no errors or warnings. Also if I upload the page as a .html file, I can view it fine remotely. I have seen a lot of other people with this error, but the 'solutions' just say to change the customErrors tag to 'Off', which I have done and does not work, do you know is there an issue with the webserver or what could be the problem here? Here is the error page: Server Error in '/'

Integrate type name in static_assert output?

為{幸葍}努か 提交于 2019-11-27 18:27:31
I like to give helpful errors / messages, and I also want to do so for my static_assert s. The problem is, that they depend on template parameters. Normally, those parameters will get displayed on way or an other due to the error raised, but they are either obscure or not grouped so they make sense. Example: template<class T> struct fake_dependency{ static bool const value = false; }; template<class T, class Tag> struct Foo{ Foo(){} template<class OtherTag> Foo(Foo<T, OtherTag> const&){ static_assert(fake_dependency<T>::value, "Cannot create Foo<T,Tag> from Foo<T,OtherTag>."); } }; int main(){

Tools to generate higher-quality error messages for template-based code?

一个人想着一个人 提交于 2019-11-27 11:20:54
问题 Concepts, that would render these tools unnecessary, are not part of C++11. STLFilt would have been one option but it is no longer maintained. Clang claims to give expressive diagnostics although important C++11 features are not available yet. colorgcc seems to be abandoned since 1999. What production quality tools are available to decipher error messages stemming from template-based code? Eclipse-CDT support would be nice too. :) If I give up on C++11, what options do I have for C++98?