问题
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