Solved

ASP.net MVC 4.0 good error message

Posted on 2014-01-19
1
159 Views
Last Modified: 2014-11-29
I want to display  nice message in ASP.net MVC 4.0 app if the URL entered by user does not match the registered routes.

Please advise the best method?
0
Comment
Question by:Jugnoo2013
1 Comment
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 500 total points
ID: 39791992
Hi,

You have to handle 404 page not found error simply.

just add following entry in web.config and add the required error page:

<customErrors mode="On" defaultRedirect="/system/problem">
    <error statusCode="404" redirect="/system/notfound" />
</customErrors>


you may found following helpful:

http://stackoverflow.com/questions/903537/handle-invalid-url-in-mvc
http://stackoverflow.com/questions/5701922/correct-404-message-for-a-missing-asp-net-mvc-controller
http://stackoverflow.com/questions/8187109/asp-net-mvc-properly-handling-invalid-urls

Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now