Note that there are some explanatory texts on larger screens.

plurals
  1. POcustomerError handling asp.net mvc4
    primarykey
    data
    text
    <p>So basically I have an Custom Authorize attribute and at some point it throwns an exception. I want to catch the exception and display the message to the user.</p> <p>this is the contoller</p> <pre><code>[HandleError] public class TestController : BaseController { [CustomAuthorize("someperm, someperm2")] public ActionResult GamblerUser() { return View(); } } </code></pre> <p>this is the code in FilterConfig</p> <pre><code>public class FilterConfig { public static void RegisterGlobalFilters(GlobalFilterCollection filters) { filters.Add(new HandleErrorAttribute()); } } </code></pre> <p>this is the code in global.asax.cs</p> <pre><code>protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); } </code></pre> <p>and the web.config</p> <pre><code>&lt;customErrors defaultRedirect="~/Shared/Error" mode="On"&gt; &lt;/customErrors&gt; </code></pre> <p>and finally the view itself</p> <pre><code>@model HandleErrorInfo @{ ViewBag.Title = "Error"; } &lt;h2&gt;Sorry Error Occured&lt;/h2&gt; &lt;br /&gt; &lt;h2&gt;@Model.Exception.Message&lt;/h2&gt; </code></pre> <p>and this is the message I get whenever the exception occurs. </p> <p>Runtime Error Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated. </p> <p>I know that I am missing something very basic but this thing is just giving me headache. I've look at tons of examples I just cant get this thing working.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload