ASP.net MVC Routing Throws Exceptions as Normal Behavour?

旧时模样 提交于 2020-01-03 05:19:12

问题


I was debugging my current project (ASP.net MVC 1.0 project) and stumbled upon slightly disturbing behavour.

It seems that when the router is hunting for a referenced partial view aka

<%Html.RenderPartial("AccountListControl", ViewData["AccountList"]); %>

It cycles through it's default locations until it finds the correct spot. So it checks "Views\Shared\AccountListControl" and checks "Views\Home\AccountListControl" etc

Once it finds a match - all is good. Bad locations are identified by the web exception thrown in each case.

Is there a significant performance cost for all of these exceptions?

Should I modify the code to be more explicit?


回答1:


It seems that in Release mode there are no exceptions thrown and view locations are cached so there is no need to be more explicit.



来源:https://stackoverflow.com/questions/1123904/asp-net-mvc-routing-throws-exceptions-as-normal-behavour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!