开发者

Detect Views that don't exist

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜