custom-errors

ASP.NET MVC 5 Custom Error Page

故事扮演 提交于 2019-11-27 10:08:20
问题 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

How does one write good error messages?

你离开我真会死。 提交于 2019-11-27 09:36:30
问题 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. 回答1: 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

ASP.NET Custom 404 Returning 200 OK Instead of 404 Not Found

一世执手 提交于 2019-11-27 06:35:19
After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page and told the browser that everything is OK. This is consider a soft 404 or false 404. Google doesn't like this. So I found many articles on the issue but the solution I want didn't seem to work. The solution I want to work is adding the following two lines to the code behind Page_Load method of the custom 404 page. Response.Status = "404 Not Found"; Response.StatusCode = 404; This doesn't work. The page still returns 200 OK

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

百般思念 提交于 2019-11-27 04:19:12
问题 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

Implementing a Custom Error page on an ASP.Net website

痞子三分冷 提交于 2019-11-27 02:40:26
问题 I have an ASP.Net website and I want to use a custom error page. I put the following code in my web.config <customErrors mode="On" defaultRedirect="~/error.aspx"> <error statusCode="404" redirect="~/error.aspx" /> </customErrors> The problem is when i go to a URL that does not exist is still uses the 404 error page specified in IIS Manager. Question: How can I make it use the error.aspx page I have created? Why do the settings in IIS Manager override the web.config? 回答1: Try this way, almost

CustomErrors does not work when setting redirectMode=“ResponseRewrite”

不打扰是莪最后的温柔 提交于 2019-11-26 19:36:39
In a old site, I was changing the way that CustomErrors works by adding redirectMode="ResponseRewrite" (new in 3.5 SP1): <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx" redirectMode="ResponseRewrite"> <error statusCode="404" redirect="404.aspx" /> </customErrors> The thing is: it shows me the generic error page (the one that you get when you don't set customErrors . If I remove the redirectMode="ResponseRewrite" part, it works fine. I'm sure 3.5 SP1 is installed in the server, because I use the same setting on other sites hosted in the same server. Any ideas? Michael Hallock It is

Integrate type name in static_assert output?

随声附和 提交于 2019-11-26 19:25:39
问题 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&){

ASP.NET Custom 404 Returning 200 OK Instead of 404 Not Found

感情迁移 提交于 2019-11-26 12:04:58
问题 After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page and told the browser that everything is OK. This is consider a soft 404 or false 404. Google doesn\'t like this. So I found many articles on the issue but the solution I want didn\'t seem to work. The solution I want to work is adding the following two lines to the code behind Page_Load method of the custom 404 page.

CustomErrors does not work when setting redirectMode=“ResponseRewrite”

狂风中的少年 提交于 2019-11-26 08:58:56
问题 In a old site, I was changing the way that CustomErrors works by adding redirectMode=\"ResponseRewrite\" (new in 3.5 SP1): <customErrors mode=\"RemoteOnly\" defaultRedirect=\"Error.aspx\" redirectMode=\"ResponseRewrite\"> <error statusCode=\"404\" redirect=\"404.aspx\" /> </customErrors> The thing is: it shows me the generic error page (the one that you get when you don\'t set customErrors . If I remove the redirectMode=\"ResponseRewrite\" part, it works fine. I\'m sure 3.5 SP1 is installed

jQuery override default validation error message display (Css) Popup/Tooltip like

橙三吉。 提交于 2019-11-26 08:39:39
问题 I\'m trying to over ride the default error message label with a div instead of a label. I have looked at this post as well and get how to do it but my limitations with CSS are haunting me. How can I display this like some of these examples: Example #1 (Dojo) - Must type invalid input to see error display Example #2 Here is some example code that overrides the error label to a div element $(document).ready(function(){ $(\"#myForm\").validate({ rules: { \"elem.1\": { required: true, digits: