0

I make use of ASP.NET 5 Areas.

In the default ASP.NET 5 project you have _ValidationScriptsPartial.cshtml in the Views\Shared folder

I can refer to it in my Areas\AreaName\Views\controllername\MyView.cshtml

as

@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }

Questions:

  1. Why can I refer to its path directly and not be forced to use

    @{await Html.RenderPartialAsync("~/Views/Shared/_ValidationScriptsPartial.cshtml"}
    

    I ask because it is sometimes confusing where it comes from as it is not an relative path. Is there a setting somewhere to enable/disable this behavior.

  2. I have various of my own scripts in location in Views\Shared as well as in my area's view folder Areas\MyArea\Views\MyControllerName\. If I have the same partial view name as in the Views\Shared folder will it take precendence?

  3. Is there a way to make the location strongly typed (i.e. give build error if not exist) or is using C# constants the best way around this? e.g.

    @{ await Html.RenderPartialAsync("_ValidationScriptsPartialNotExist"); }
    

does not give an error or warning or red line underneath

dfmetro
  • 4,462
  • 8
  • 39
  • 65
  • 2
    Because the ViewEngine always search the `Views\Shared` folder if the view is not found in the specific controller's view folder –  Jan 29 '16 at 12:09
  • If you want to configure where views are searched, you can create your own as per [these answers](http://stackoverflow.com/questions/909794/how-to-change-default-view-location-scheme-in-asp-net-mvc) –  Jan 29 '16 at 12:12
  • Thanks, do you know how to make it strongly typed? – dfmetro Jan 29 '16 at 12:18

0 Answers0