Does ASP.NET MVC 2.0 use exceptions to control flow?

Following the code exceptions (processed), it appears that MVC uses exceptions to check for management locations.

<% Html.RenderPartial("LogOnUserControl"); %>

The application works as expected, I see that this exception generates a couple of attempts in different places (Views, Shared). The same thing happens with other controls. Apparently MVC uses exceptions to check for various possible locations for a file.

IIRC using flow control exceptions is evil, and it's not cool. So am I doing something wrong or is MVC not cool anymore?

Note. When the IDE stops in all excepted exceptions, debugging is simplified, and I usually leave it turned on. Here's how I got to this exception from RenderPartial.

+3
source share
2 answers

It is not true that MVC 2.0 uses exceptions for the control flow.

However, System.Web.dll v2.0 (the main component of ASP.NET before .NET 3.5) has some inefficient APIs for creating objects from virtual paths. MVC 2.0 mitigates this problem by using a view cache. By default, this cache is disabled during development, so the changes you make are immediately visible, so you see these exceptions. On a real production server, these exceptions will not occur after caching search queries.

As an additional note, MVC 3 will use the new APIs added in .NET 4, so this should no longer be a problem.

+3
source

When launched in Release mode, view modes are cached.

+2

Source: https://habr.com/ru/post/1764177/


All Articles