asp.net-mvc IIS 6.0 突然显示目录列表而不是 MVC 3 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8723763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IIS 6.0 suddenly shows directory listing instead of MVC 3 app
提问by Anders Arpi
Over night an (internal, luckily) MVC web application has stopped working for me, without anything being changed as far as I know. The application itself absolutely hasn't been tinkered with in the last two days and the same goes for IIS.
一夜之间,一个(内部的,幸运的是)MVC Web 应用程序停止了对我的工作,据我所知,没有任何改变。应用程序本身在过去两天绝对没有被修改过,IIS 也是如此。
The problem is that I get a directory listing of my www-folder instead of the applications default action (/Home/Index).
问题是我得到了 www 文件夹的目录列表,而不是应用程序默认操作 ( /Home/Index)。
My www-folder contains the standard stuff:
我的 www 文件夹包含标准的东西:
bin
Content
Scripts
Views
Global.asax
Web.config
I have tried:
我试过了:
- setting a "Specific Page" as Start Action but it doesn't solve the problem.
- restarting the web page in IIS
- enable/disabled "default content page" in IIS. Doesn't help, but IIS does pick up on a Default.html if I place it in the www-folder.
- 将“特定页面”设置为开始操作,但并不能解决问题。
- 在 IIS 中重新启动网页
- 在 IIS 中启用/禁用“默认内容页面”。没有帮助,但如果我将它放在 www 文件夹中,IIS 确实会选择 Default.html。
Now, this has happened once before. At the time I was on vacation and it was solved by restarting the entire World Wide Web Publishing Service. While it might work this time as well, I'd rather figure out the root of the problem before temporarily fixing it just to have it happen again further down the road. So while a WWW Publishing Service restart might get the site running again I'd rather understand why it happened in the first place before fixing it this way.
现在,这已经发生过一次了。当时我正在休假,通过重新启动整个万维网发布服务解决了这个问题。虽然这次它也可能工作,但我宁愿在暂时修复它之前找出问题的根源,只是为了让它在更远的地方再次发生。因此,虽然重新启动 WWW 发布服务可能会使站点再次运行,但我更愿意在以这种方式修复它之前先了解它为什么会发生。
Finally, note that I'm running other MVC apps on the same IIS server and have never gotten this problem with them.
最后,请注意,我在同一台 IIS 服务器上运行其他 MVC 应用程序,但从未遇到过这个问题。
采纳答案by Siddhant
I had a similar problem. The IIS root path had been changed by a collegue. The solution was to fix the "Physical Path" in the "Advanced Settings" of the Default Web Site.
我有一个类似的问题。IIS 根路径已被同事更改。解决方案是修复默认网站“高级设置”中的“物理路径”。
回答by Afshin Mehrabani
- Open Command prompt
- Go to
C:\Windows\Microsoft.NET\Framework\<version>folder. - Run
aspnet_regiis -i
- 打开命令提示符
- 转到
C:\Windows\Microsoft.NET\Framework\<version>文件夹。 - 跑
aspnet_regiis -i
That's all!
就这样!
回答by kingPuppy
A little late.... But as I was receiving the same result.
有点晚了......但因为我收到了同样的结果。
My Application Pool was targeting the wrong .Net version (should be same as web app Target Framework). Simply adjusted within the "Set Application Pool Defaults" option, restarted and it was solved.
我的应用程序池针对错误的 .Net 版本(应该与 Web 应用程序目标框架相同)。只需在“设置应用程序池默认值”选项中进行调整,重新启动即可解决。
Hope it helps someone.
希望它可以帮助某人。
回答by Alexander Beletsky
I don't think /Home/Index is possible to run om IIS 6.0 with out any configuration. ASP.NET MVC actually requires "Intergrated Mode", but could be run on classic with applying configuration.
我认为 /Home/Index 不可能在没有任何配置的情况下运行 IIS 6.0。ASP.NET MVC 实际上需要“集成模式”,但可以通过应用配置在经典上运行。
That article by mister Haack, could be helpful: http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
Haack 先生的那篇文章可能会有所帮助:http: //haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
回答by user1216363
Saw this problem when I added a folder called "documents" at the root and also had a DOCUMENTS controller & view. I think it was confused if I wanted the route \documents which is in the CONTROLLER folder or the \documents folder below the root. One solution was to add an id to the route which makes it use the controller version of documents
当我在根目录添加一个名为“documents”的文件夹并且还有一个 DOCUMENTS 控制器和视图时看到了这个问题。我认为如果我想要位于 CONTROLLER 文件夹中的路径 \documents 或根目录下的 \documents 文件夹,我会感到困惑。一种解决方案是向路由添加一个 id,使其使用文档的控制器版本
Url.Action("Index", "Documents", *New With {.id = 1}*)
Url.Action("Index", "Documents", *New With {.id = 1}*)
Can also change the name of the newly added folder below the root to DOCS.
也可以将新添加的根目录下的文件夹名称改为DOCS。
回答by Shyam Kumar
Changing the .NET CLR version of the application pool might help.
更改应用程序池的 .NET CLR 版本可能会有所帮助。
- Right clickon the application pool in which your application is running and select Advanced Settings...
- Change the .NET CLR VERSIONto the version of your application(same as that in the config files)
- Click ok
- 右键单击运行您的应用程序的应用程序池,然后选择高级设置...
- 将 .NET CLR VERSION 更改为您的应用程序版本(与配置文件中的版本相同)
- 单击确定
回答by CodeZen
I had the same problem and here is how I resolved it.
我遇到了同样的问题,这是我解决的方法。
I had a problem with the Global.asax file on the TFS server inheriting from the WebAPI project (and not the web project) although the web project was chosen as the startup project in Visual Studio. When I ran my build the Web API was set as the start up project on the web server since it was deploying the version on the TFS server that was inheriting from the WebAPI project. To resolve this I set another project as the startup project and then changed the web project to be the startup project again in Visual studio. I had to do this since TFS complained that there were no pending changes when I tried to check the version I had on my machine into TFS. I then checked my code in and ran the build again. This resolved my issue.
尽管 Web 项目被选为 Visual Studio 中的启动项目,但我在继承自 WebAPI 项目(而不是 Web 项目)的 TFS 服务器上的 Global.asax 文件方面遇到了问题。当我运行我的构建时,Web API 被设置为 Web 服务器上的启动项目,因为它正在从 WebAPI 项目继承的 TFS 服务器上部署版本。为了解决这个问题,我将另一个项目设置为启动项目,然后在 Visual Studio 中再次将 Web 项目更改为启动项目。我不得不这样做,因为当我尝试将我机器上的版本检查到 TFS 时,TFS 抱怨没有挂起的更改。然后我检查了我的代码并再次运行构建。这解决了我的问题。


