I want to be able to request static .html files that are in the ~ / Views folder.
Good. The noted answer is not entirely correct, although it gives a solution.
The arguments given in the correct answer are correct: in the "Views" folder, which prohibits access to files directly, web.config is set (BlockViewHandler parameter). It is designed to protect views in Asp.Net MVC. But if you asked a question about servicing these files directly, then you probably have good reason for this, for example, to use partial views of AngularJS (as in our case), where we do not want to duplicate the views folder with strange names.
So, here is a very simple setup that you can do in the web.config file found in the Views folder, without compromising the security of your asp.net mvc views. This will provide .cshtml files as usual, but leave only your .html files.
Change it
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
- at -
<add name="BlockViewHandler" path="*.cshtml" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
Vikas Jul 16 '14 at 19:27 2014-07-16 19:27
source share