ASP.net MVC路由将异常作为正常行为?

时间:2021-07-10 04:05:07

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

我正在调试我当前的项目(ASP.net MVC 1.0项目),偶然发现了一些令人不安的行为。

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

它循环通过它的默认位置,直到找到正确的位置。因此它检查“Views \ Shared \ AccountListControl”并检查“Views \ Home \ AccountListControl”等

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

一旦找到匹配 - 一切都很好。错误的位置由每种情况下抛出的Web异常标识。

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

所有这些例外都有显着的性能成本吗?

Should I modify the code to be more explicit?

我应该修改代码更明确吗?

1 个解决方案

#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.

似乎在Release模式下没有抛出异常并且视图位置被缓存,因此不需要更明确。

#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.

似乎在Release模式下没有抛出异常并且视图位置被缓存,因此不需要更明确。