简体   繁体   English

模板MVC应用程序可用作网站,但不能用作IIS应用程序

[英]Template MVC application works as website but not as IIS application

I have: 我有:
- Windows 7 - Windows 7的
- unmodified template MVC 4.0 Internet Application -未修改的模板MVC 4.0 Internet应用程序
- IIS 7.5 -IIS 7.5

The site works fine if I set it up as Site in IIS. 如果我将其设置为IIS中的站点,则该站点可以正常工作。 If I set it up as an Application in IIS, it displays a blank page. 如果我将其设置为IIS中的应用程序,它将显示空白页。 Nothing appears in Application error log in Event Viewer. 事件查看器中的“应用程序错误”日志中没有任何内容。

  1. I'm using the same App pool (4.0, Integrated) for both scenarios. 对于两种情况,我都使用相同的应用程序池(4.0,集成)。
  2. Adding <modules runAllManagedModulesForAllRequests="true"></modules> didn't help. 添加<modules runAllManagedModulesForAllRequests =“ true”> </ modules>并没有帮助。
  3. Http Errors and Http Redirection Windows features are turned on. Http错误和Http重定向Windows功能已打开。
  4. I have registered aspnet_regiis.exe -i (for both 32 and 64 bit) 我已经注册了aspnet_regiis.exe -i(32位和64位)
  5. There are no permission restrictions on the folder or any files. 该文件夹或任何文件没有权限限制。

I put a Default.html file inside the folder. 我将Default.html文件放在文件夹中。 I can browse to it on a Site. 我可以在网站上浏览到它。 If I try to browse to it in an Application, it displays a blank page. 如果我尝试在应用程序中浏览到它,它将显示一个空白页。

How do I run the site as an application? 如何将网站作为应用程序运行?

You need to publish your application. 您需要发布您的应用程序。 Right click on your project, select "Publish", select some folder. 右键单击您的项目,选择“发布”,选择一些文件夹。 After success you must place all files into folder on IIS server and show this folder for IIS web site. 成功后,您必须将所有文件放入IIS服务器上的文件夹中,并为IIS网站显示此文件夹。 On other side, you can publish your app straight to IIS server, with your http address ) 另一方面,您可以使用http地址将应用程序直接发布到IIS服务器。

It must be a problem with the IIS application configuration. IIS应用程序配置一定有问题。

When you say you're deploying your app as a site in IIS, what you are really doing is deploying your application to the root application of the IIS site, not to the site itself. 当您说要将应用程序部署为IIS中的站点时,实际上是在将应用程序部署到IIS站点的根应用程序,而不是站点本身。

So, the problem is with the configuration of the application inside the site. 因此,问题在于站点内部应用程序的配置。

To understand how this works, and you can have misconfigured, look at this document: 要了解其工作原理以及配置错误,请查看以下文档:

Understanding Sites, Applications, and Virtual Directories on IIS 7 了解IIS 7上的站点,应用程序和虚拟目录

which has a clear explanation of what you are doing, and why it isn't working. 其中清楚地说明了您在做什么以及为什么它不起作用。 It could be the fault of a web.config file in your site, or any other inherited configuration. 可能是您网站中的web.config文件或任何其他继承的配置有问题。 Or simply that you're not accessing the application as you expect. 或者只是因为您没有按预期访问应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM