Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access HTML files from ASP.NET MVC VIEWS Folder

I will like add conventional HTML page under VIEWS folder (in ASp.NET MVC) page. I have added the route exceptions as mentioned below.

    routes.IgnoreRoute("{resource}.htm/{*pathInfo}")
    routes.IgnoreRoute("{resource}.html/{*pathInfo}")

Although it does work when I put the html files out of VIEWS folder but I get Page not found 404 when I put those in VIEWS folder. I am also unable to browse the VIEWS folder by setting directory browsing option in IIS.

Please help me on HOW to access HTML file from VIEWS folder.

like image 243
Sumanta Avatar asked Jul 06 '09 16:07

Sumanta


1 Answers

I think that it's a mistake to mix your HTML content with your views. I'd suggest that you create a separate static folder under Content and put your HTML there. You can create an analogous directory structure to your view structure if necessary for management. Then you don't need to do anything special in order to able to reference the files. You can even, then, open them up to editing with Contribute, etc. by people who are allowed to modify static content.

 +-Content
   +-Images
   +-Static
      +-Account
         +-privacy.html
         +-refunds.html
   +-Styles

Usage:

 <a href='<%= Url.Content( "~/Content/Static/Account/privacy.html" ) %>'>Privacy Policy</a>
like image 57
tvanfosson Avatar answered Oct 28 '22 04:10

tvanfosson