views:

283

answers:

2

Hi All,

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.

+1  A: 

The default Views folder has an Web.config file that explicitly gives 404 errors for all requests. You just need to edit and enable for HTML files (or all files, but then people might snoop).

Thomas G. Mayfield
+3  A: 

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>
tvanfosson
+1 for keeping Views folder strictly for Views.
Dennis Palmer