简体   繁体   English

MVC3加载启动页面错误

[英]MVC3 load start up page error

Ok, So as a company we deployed our first MVC3 application on a web server. 好的,因此,作为一家公司,我们在Web服务器上部署了第一个MVC3应用程序。 Which has been set up to handle .NET 已设置为处理.NET

The server uses Windows Server 2008 and IIS 7. 该服务器使用Windows Server 2008和IIS 7。

However when we point the browser to the URL we receive this error. 但是,当我们将浏览器指向URL时,会收到此错误。

Directory Listing Denied This Virtual Directory does not allow contents to be listed. 目录列表被拒绝此虚拟目录不允许列出内容。

When we point it to a known path such as: 当我们将其指向已知路径时,例如:

http://websitename/subfolder/subfolder/Views

We get the same error. 我们得到同样的错误。 Clearly when ww try to go directly to the Razor page, for example: 显然,当ww尝试直接转到Razor页面时,例如:

http://websitename/subfolder/subfolder/Views/Pages/Index.cshtml

As you would expect it downloads the .cshtml file, because the browser can't read .cshtml, it reads the generated .html. 如您所料,它将下载.cshtml文件,因为浏览器无法读取.cshtml,因此它将读取生成的.html。

if I point to: 如果我指出:

http://websitename/subfolder/subfolder/Views/Pages/Index.html

It cant find anything. 它找不到任何东西。

It works running on localhost through Visual Studio. 它可以通过Visual Studio在本地主机上运行。 and when published the start up page is just the root and it runs and directs to the correct place through VS. 发布时,启动页面只是根目录,它会运行并通过VS定向到正确的位置。

My question is how do you point to the generated html on a web server manually, or is there a reason it isn't finding the start page when I just go to the root on the server? 我的问题是,如何手动指向Web服务器上生成的html,还是有一个原因,当我仅转到服务器的根目录时,找不到起始页?

I have check the IIS and made sure that the correct things are set to local copy 'true', and I have also added runAllManagedModulesForAllRequests=”true” to my web.config file. 我已经检查了IIS,并确保将正确的内容设置为本地副本“ true”,并且还向我的web.config文件中添加了runAllManagedModulesForAllRequests =“ true”。

Any help or a point in the right direction would be appreciated. 任何帮助或朝着正确方向的观点将不胜感激。

In MVC you don't access the views via the browser, you access actions on the controller, and they in turn return a view. 在MVC中,您不通过浏览器访问视图,而是访问控制器上的操作,它们又返回一个视图。

So you should be trying to access 因此,您应该尝试访问

http://websitename/controller/action

The controller part is the name of a controller with the "controller" bit lobbed off the end, eg to access a Login action on the AccountController you would go to 控制器部分是控制器的名称,其末尾带有“ controller”位,例如,要访问AccountController上的Login操作,您将转到

http://websitename/Account/Login

You're actions should be defined something like this in your controllers 您的动作应该在控制器中定义如下

public ActionResult Login(string username, string password)

似乎您尚未安装.NET4。请您能阐明服务器设置,例如OS,IIS版本等吗?

For some reason the requests are not going from the IIS to the ASP.Net runtime. 由于某些原因,请求不会从IIS发送到ASP.Net运行时。 This is configured differently (or doen't need to be at all) depending on the version of IIS you are using (which also depends on Server-OS you are using). 根据您使用的IIS版本(也取决于您使用的Server-OS),对它进行了不同的配置(或根本不需要配置)。 On some older versions of IIS (eg. Version) in MVC-Routing you have to add a .aspx (or any other extension) to all your routes (see Global.asax) and then configure IIS to route all the .aspx requests to the ASP.Net subsystem. 在MVC路由中的某些较旧版本的IIS(例如,版本)上,您必须将.aspx(或任何其他扩展名)添加到所有路由(请参阅Global.asax),然后将IIS配置为将所有.aspx请求路由到ASP.Net子系统。 Newer versions of IIS don't need all of this. 较新版本的IIS不需要所有这些。

The following tutorial from MS may help: http://www.asp.net/mvc/tutorials/older-versions/deployment/using-asp-net-mvc-with-different-versions-of-iis-cs 来自MS的以下教程可能会有所帮助: http : //www.asp.net/mvc/tutorials/older-versions/deployment/using-asp-net-mvc-with-different-versions-of-iis-cs

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

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