-1

I have a simple ASP.NET MVC 5 project, i created a folder called static then created this html page inside it > static.html:

    <!DOCTYPE html>
<html>
<head>
    <title>Hello </title>
    <meta charset="utf-8" />
</head>
<body>
<form action="/Customer/HelloTest" method="post">
    <input type="text" value="ID"> <input type="text" name="Id" />
    <input type="text" name="username" />
    <input type="text" name="customers[0].id" />
    <input type="text" name="customers[0].username" />
    <input type="text" name="names" />
    <input type="text" name="names" />
    <input type="submit" />
</form>
</body>
</html>

I hosted this application on IIS.

When i run the solution and try to open the page like this:

http://localhost/FirstMVCWebApp/static/static.html

I faced only a blank page, so i don't know why this didn't open my html page, is this related to routing, should i put any route configurations or what?

I think the peoblem related to IIS as when i used IIS Express to run my web application instead of local IIS host, every things worked correctly.

Marzouk
  • 2,650
  • 3
  • 25
  • 56
  • Create a view in MVC which should be independent for project layout project for your plain html – Sachink Aug 21 '15 at 09:05
  • 1
    I need to only create a html page and called it direct without creating a view and called it via Action in a controller, is it possible i read this here: http://stackoverflow.com/questions/17949460/how-do-you-request-static-html-files-under-the-views-folder-in-asp-net-mvc – Marzouk Aug 21 '15 at 09:07

2 Answers2

0

You can use Url.Content() to open your static html page as below:

<a href ="@Url.Content("~/static/static.html")" target="_blank">Open Static Page</a>
Pawan
  • 1,704
  • 1
  • 16
  • 37
  • I think the peoblem related to IIS as when i used IIS Express to run my web application instead of local IIS host, every things worked correctly. – Marzouk Aug 21 '15 at 09:49
0

OK, That's my answer to my question, i found that this issue didn't related to MVC, its related to IIS.

When IIS get the HTTPRequest, the first thing IIS do is to search for appropriate handler to handle it.

Handlers have lot of details, but the issue here is the handler for any static page called 'StaticFile' get the extensions of the static file that it can handle from 'MIME Types', and 'MIME Types' is a configurations located in IIS, but in my case there was no MIME Types to specify the extensions of static file so i goto and install it from Add features in control panel > IIS > StaticContent feature

Marzouk
  • 2,650
  • 3
  • 25
  • 56