handleerror

ASP.NET MVC user friendly 401 error

☆樱花仙子☆ 提交于 2020-01-09 06:48:07
问题 I have implemented errors handling in ASP.NET MVC site in a way like suggests this post. With 404 errors all works fine. But how correctly show user friendly screen for a 401 error ? They usually do not throw Exception that can be handled inside Application_Error() but rather action returns HttpUnauthorizedResult. One possible way is to add following code to the end of Application_EndRequest() method if (Context.Response.StatusCode == 401) { throw new HttpException(401, "You are not

MVC HandleError returns error 500 and view error page

ⅰ亾dé卋堺 提交于 2019-12-23 18:52:52
问题 I am using MVC 3 with VS2010 and trying to get [HandleError] working. I created a test in the controller to simulate a crash as follows: [HandleError] public ActionResult Crash() { throw new ApplicationException(); } Also went into web.config and added: <customErrors mode="on" /> If I run from Chrome, MVC returns the view in Shared/Error.aspx, so this work ok. If I run from IE 8, I get its friendly error page ("The website cannot display the page, Most likely causes: ... What you can try...")

HandleError attribute doesn't have any effect

不羁的心 提交于 2019-12-08 17:20:46
问题 In my web.config I have included: <customErrors mode="On" /> Now the yellow screen of death isn't shown anymore. I thought I'd have to include the HandleError attribute to my controller methods or the class itself: [HandleError] public ActionResult About() { throw new Exception("Just an exception"); return View(); } But it doesn't have any effect, it's the same as: public ActionResult About() { throw new Exception("Just an exception"); return View(); } In both cases the custom error page is

ASP.NET MVC HandleError View Not Found

*爱你&永不变心* 提交于 2019-12-06 11:07:44
问题 I'm trying to implement exception handling in ASP.NET MVC3 using the HandleError attribute. The code that I'm using looks like this: [HandleError(Order = 1, ExceptionType = typeof(SocketsOfflineException), View="EndSystemDownError")] This works as expected when the EndSystemDownError view is located in the "Shared" folder. However, I have a number of Error views, and I want to separate them out into a folder specifically for Errors, called "Error". So I pull the EndSystemDownError view out of

ASP.NET MVC HandleError View Not Found

六眼飞鱼酱① 提交于 2019-12-04 17:06:49
I'm trying to implement exception handling in ASP.NET MVC3 using the HandleError attribute. The code that I'm using looks like this: [HandleError(Order = 1, ExceptionType = typeof(SocketsOfflineException), View="EndSystemDownError")] This works as expected when the EndSystemDownError view is located in the "Shared" folder. However, I have a number of Error views, and I want to separate them out into a folder specifically for Errors, called "Error". So I pull the EndSystemDownError view out of the shared folder and into an "Error" subfolder in the Views folder. I then update the View property

How can I make HandleErrorAttribute work with Ajax?

狂风中的少年 提交于 2019-12-04 03:28:42
问题 In my ASP.NET MVC 2 application I use HandleErrorAttribute to display a custom error page in case of unhandled exceptions, and it works perfectly unless the exception happens in an action called by Ajax.ActionLink. In this case nothing happens. Is it possible to use HandleErrorAttribute to update the target element with the contents of an "Error.ascx" partial view? 回答1: To achieve this you could write a custom action filter: public class AjaxAwareHandleErrorAttribute : HandleErrorAttribute {

ASP.NET MVC - How to throw a 404 page similar to that on StackOverflow

纵饮孤独 提交于 2019-12-03 06:02:48
问题 I've currently got a BaseController class that inherits from System.Web.Mvc.Controller . On that class I have the HandleError Attribute that redirects users to the "500 - Oops, we screwed up" page. This is currently working as expected. THIS WORKS <HandleError()> _ Public Class BaseController : Inherits System.Web.Mvc.Controller ''# do stuff End Class I also have my 404 pages working on a Per-ActionResult basis which is again working as expected. THIS WORKS Function Details(ByVal id As

How can I make HandleErrorAttribute work with Ajax?

别来无恙 提交于 2019-12-01 18:22:00
In my ASP.NET MVC 2 application I use HandleErrorAttribute to display a custom error page in case of unhandled exceptions, and it works perfectly unless the exception happens in an action called by Ajax.ActionLink. In this case nothing happens. Is it possible to use HandleErrorAttribute to update the target element with the contents of an "Error.ascx" partial view? To achieve this you could write a custom action filter: public class AjaxAwareHandleErrorAttribute : HandleErrorAttribute { public string PartialViewName { get; set; } public override void OnException(ExceptionContext filterContext)

MVC HandleError filter didn't catch an exception

早过忘川 提交于 2019-11-30 09:26:26
问题 I've an MVC 3 web app in which I'm using " HandleError " Action Filter for exception handling. I've this action filter implemented as follows: [HandleError] public class BaseController : Controller {...} This is the base class from which all of my controllers are derived. In my web.config I've and there's an Error.cshtml in my Shared folder (.cshtml because I use Razor). Everything has been working fine and I get a fine exception handling (formatted by my function) Recently, somehow I got and

When was handleError removed from jQuery?

萝らか妹 提交于 2019-11-29 09:20:17
I'm revisiting some old code, and have found it doesn't work with jQuery 1.6 because it cannot find $.handleError() . A quick search of the jQuery code shows nothing, so I guess this function has been removed/replaced. Does anyone know which version the handleError function was first missing from, and if it has a direct replacement? It looks like handleError() was removed in jQuery 1.5. Most solutions I've seen online create their own error functions . Hope that helps 来源: https://stackoverflow.com/questions/6329589/when-was-handleerror-removed-from-jquery