开发者

Detect Views that don't exist

开发者 https://www.devze.com 2023-03-04 05:01 出处:网络
I have a new ASP.NET MVC 2 Website which is going to replace an old php site. I want to make sure that if any old favourites are used it will show a 404 not found message. I have trapped 404 in the We

I have a new ASP.NET MVC 2 Website which is going to replace an old php site. I want to make sure that if any old favourites are used it will show a 404 not found message. I have trapped 404 in the Web.config which works when an incorrect url is used e.g. (/Sales/MyView). But it returns an application error for the following example (/Sales), i.e. when only a controller name i开发者_JS百科s used without an action.

Is there a way to trigger a 404 error in this senario to avoid any application errors.

Cheers, Andrew


In your global.asax, you can specify the default MapRoute for the Sales controller as your 404 page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号