How do I redirect the user to the main page of the app if it tries to access an invalid url . For example, www.teste/teste.html
, in case the page does not exist then system directs the user to www.teste/index.html
, in case I am using asp.net MVC5 .
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/Views/Home/Index">
<error statusCode="500" redirect="~/Erro" />
</customErrors>
When I access a non-existent page it returns the message:
400 bad request
Can anyone help me with this question?