How to handle invalid URLs in MVC?
For ex.: When the user enters http://localhost/User/MyProfile instead of
http://localhost/User/Profile, it will throw an exception.
How to handle this request?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need first to add a custom Error page url in the web.config:
And add a controller to handle the invalid urls:
And if you want to redirect the user to the home page then you don’t need the Error controller just modify the custom error tag: