在我的MVC 5项目中,在本地IIS上工作时无法访问静态html页面 [英] In My MVC 5 project, i can't access static html page when working on Local IIS

查看:47
本文介绍了在我的MVC 5项目中,在本地IIS上工作时无法访问静态html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的ASP.NET MVC 5项目,我创建了一个名为static的文件夹,然后在其中创建了这个html页面> static.html:

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>

我将此应用程序托管在IIS上.

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

我只面对一个空白页面,所以我不知道为什么它没有打开我的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?

我认为与IIS相关的问题是,当我使用IIS Express而不是本地IIS主机运行Web应用程序时,一切正常.

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.

推荐答案

好,这是我对问题的回答,我发现此问题与MVC不相关,而MVC与IIS有关.

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

当IIS获得HTTPRequest时,IIS要做的第一件事就是搜索适当的处理程序来处理它.

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

处理程序有很多细节,但是这里的问题是任何名为'StaticFile'的静态页面的处理程序都可以从'MIME Types'获取静态文件的扩展名,而'MIME Types'是位于以下位置的配置在IIS中,但是在我的情况下,没有MIME类型指定静态文件的扩展名,因此我转到控制面板> IIS> StaticContent功能中的添加功能"并安装它

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

这篇关于在我的MVC 5项目中,在本地IIS上工作时无法访问静态html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆