model view controller - CustomErrors not redirecting to custom page but MVC default error page -


i have new mvc 4.0 solution created scratch using vs2012 web express , iis express. tile says changed web.config , added following in :

<customerrors defaultredirect="errors/genericerror.html" mode="on">     <error statuscode="404" redirect="errors/error404.html"/> </customerrors> 

basically when exception in controller default mvc error.cshtml showing error instead of custom page genericerror.html.

if go url doesn't exist, error404.html showing correctly not generic scenario.

any ideas how can change behavior?

sounds don't have error attribute in global filters. in mvc 4 project should able search class filterconfig generated you:

public class filterconfig {     public static void registerglobalfilters(globalfiltercollection filters)     {         filters.add(new handleerrorattribute());     } } 

update:

the handleerrorattribute global filter errors occur in mvc pipeline, such errors in controller mention.

the customerrors element in web.config else. handleerrorattribute not honor value put in defaultredirect attribute of customerrors.

the handleerror filter shared view should have in generated project shared\error.cshtml. can point different view setting property on attribute.

for example, let's create new view under shared\errors\customerror.cshtml, register filter this:

filters.add(new handleerrorattribute(){view = "errors/customerror"}); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -