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
Post a Comment