suppose this is my route which expect integer data for productid
routes.MapRoute(
"Product",
"Product/{productId}",
new {controller="Product", action="Details"},
new {productId = @"\d+" }
);
so these route will work
/Product/3
/Product/8999
how could i redirect user to a preexisting view where i can show a friendly error message for this scenario?
one more things i like to know can we set status code when user will type /Product/apple
and this route will not match any. so in this case i like to set statusCode="404"
. if i can do it then below customErrors
where i specified a view will be shown for 404 error. suggest me how to do it?
<customErrors mode="Off" defaultRedirect="~/error.html">
<error statusCode="403" redirect="~/access-denied.aspx" />
<error statusCode="404" redirect="~/page-not-found.aspx" />
<error statusCode="500" redirect="~/error.html" />
</customErrors>
please guide me if it is possible.