asp.net mvc - Return 404 if parameter type is wrong -


i interested know if there general way resolve issue. lets of actions expect id parameter passed, @ point user may try assign string id parameter url. result our action not fired , 500 exception thrown in base class. there way resolve , throw 404 exception instead?

you can put contraints on route. can find tutorial here

http://www.asp.net/mvc/tutorials/controllers-and-routing/creating-a-route-constraint-cs

then putting string instead of id not match route.

the alternatives create exception filter in mvc/webapi handle exceptions , condition, or create custom route handler.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -