ASP.NET Core 2.0 only searches in public folders

Something unobvious (or not explicitly found through Google-foo) changed in ASP.NET Core 2.0 as to how it finds views. All views related to the generic route of the area ( "{area:exists}/{controller=Home}/{action=Index}/{id?}") will perform its actions and find the view associated with them, as expected, but if I specify a less general route like "Forums/Recent/{page?}", it will not find the view. I can’t emphasize enough, the code in the controller’s action is triggered, so it correctly uses the route. He is simply not looking for a point of view in the right place. He looks only in shared places:

InvalidOperationException: The view 'Recent' was not found. The following locations were searched:
/Areas/Forums/Views/Shared/Recent.cshtml
/Views/Shared/Recent.cshtml

It does not look in /Areas/Forums/Views/Forum/Recent.cshtml, which by agreement corresponds to the controller.

My controllers are not in the same project as the views, if that matters. Again, the controller action is performed, but it does not even look in the right place for the presentation. It worked correctly in version 1.1.

+4
source share
1 answer

It turns out that this is a bug in the view engine that appears when you have a “page” in the route definition. Bits that are looking for performance do not look in the right place:

https://github.com/aspnet/Mvc/issues/6660

The team transferred the error to version 2.0.1:

https://github.com/aspnet/Mvc/milestone/38

+7
source

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


All Articles