Saturday 17 August 2013

How to return 404 page in ASP .NET MVC when query string parameters is incorrect

How to return 404 page in ASP .NET MVC when query string parameters is
incorrect

Let's imagine I have the following action
public ViewResult Products(string color)
{...}
and route which maps url "products" to this action.
According to SEO tips link /products?color=red should return
200 OK
But link /products?someOtherParametr=someValue
404 Not found
So the question is - how to handle unexisting query parameters and return
404 in this case

No comments:

Post a Comment