IIS用于ASP.NET MVC3文件(.cshtml)返回404 [英] IIS returns 404 for ASP.NET MVC3 file (.cshtml)

查看:2031
本文介绍了IIS用于ASP.NET MVC3文件(.cshtml)返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有标准的ASP.NET应用4。这里面的应用程序也有几个剃须刀(例如 test.cshtml )的文件。 ASP.NET应用程序的工作但是如果我点浏览器 /测试文件(没有扩展名)。 IIS(静态文件处理程序)将返回404。

I have standard ASP.NET 4 application. Inside this application there are also few razor (e.g. test.cshtml) files. ASP.NET application works however if I point browser to /test file (without extension). IIS (static file handler) returns 404.

同一个应用程序,甚至独立的 .cshtml 文件正在本地机(带IIS7.5 / Win7的),并在服务器上(IIS7.5 / Win2008R2) ,但它不工作,IIS7.0 /的Win2008服务器。

The same application and even the standalone .cshtml files are working on local machine (with IIS7.5/Win7) and a server with (IIS7.5/Win2008R2), however it does not work the server with IIS7.0/Win2008.

MVC3安装在两台机器上,在两台机器上的应用程序池是.NET 4.0的集成。

MVC3 is installed on both machines, app pools on both machines are .NET 4.0 integrated.

如何在 .cshtml 处理工程?当IIS决定使用静态文件处理程序,当 .cshtml 处理?还有什么我应该检查?

How the .cshtml handlers works? When the IIS decides to use static file handler and when the .cshtml handler? What else should I check?

修改

澄清 - 我没有实际使用整个MVC框架,它​​就像普通老式.ASPX或PHP文件。无控制器,无路线,没有意见。我使用它在除旧ASP.NET应用程序的简单脚本。

Clarification - I am not actually using whole MVC framework, it is just like plain-old .ASPX or PHP file. No controllers, no routes, no 'views'. I am using it for a simple script in addition to old ASP.NET application.

我觉得这不是一个编程问题,因为它工作的本地计算机上,而是配置问题 - 在IIS中的Win2008服务器上可能未正确配置

I think it is not a programming issue, since it works on local computer, but rather a configuration issue - the IIS on the Win2008 server might not be configured properly.

EDIT2:

(机械与IIS7.5的作品,只能用IIS7.0机器不工作,但我不知道它是否是IIS版本的一个问题。)

(Machines with IIS7.5 works, only machine with IIS7.0 does not work. But I am not sure whether it is a problem of IIS version.)

EDIT3:

在我在那里工作的本地计算机上,我没有设置任何路由。在$ C $他妈的和Keith建议我需要有一个路由的地方。也许是的,但它不是我的应用程序。它可能在默认情况下IIS配置的某个地方进行设置。

On my local computer where it works, I have not set any routing. TheCodeKing and Keith suggested that I need to have a routing somewhere. Maybe yes, but it is not in my application. It might be set by default somewhere in IIS configuration.

你有哪里这个'隐'的路由可以找到任何提示?

EDIT4:

请注意:在所有计算机上有 HttpForbiddenHandler * CSHTML ,因为你不能下载CSHTML文件。而且里面还有 TransferRequestHandler * 。 (两者都启用。)

Note: On all computers there is HttpForbiddenHandler for *.cshtml, since you cannot download the cshtml file. And there is also the TransferRequestHandler for *.. (Both are enabled.)

EDIT5:

我发现了服务器,在那里工作,我需要在网站根目录的 .cshtml 文件。如果我从Web根目录中删除 .cshtml 并尝试从一个子目录调用任何它不会工作。

I have found that on the servers, where it is working, I need to have any .cshtml file in the web root. If I remove the .cshtml from the web root and try to invoke any from a subdirectory it will not work.

EDIT6:

我试过在另一个两台机器:一个 IIS 7.5 和另一个与 IIS 7.0 。在 IIS 7.5 它的工作原理(普通装任何配置),但 IIS 7.0 这是行不通的。

I tried that on another two machines: one with IIS 7.5 and another with IIS 7.0. On IIS 7.5 it works (plain install no configuration), but on IIS 7.0 it does not work.

如何使它在IIS 7.0上运行?

推荐答案

耶!经过奋力几天我发现它的!))

,使其在工作的一种方式IIS 7.0 是让 runAllManagedModulesForAllRequests

<modules runAllManagedModulesForAllRequests="true" />

(虽然,在 IIS 7.5 它的工作原理,即使默认值 runAllManagedModulesForAllRequests =FALSE

(Although, on IIS 7.5 it works even with the default value runAllManagedModulesForAllRequests="false".)

不要问我为什么:)的也许有人可以解释

这篇关于IIS用于ASP.NET MVC3文件(.cshtml)返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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