简体   繁体   English

Windows Server 2008 R2上的.NET Framework 4 RTM

[英].NET Framework 4 RTM on Windows server 2008 R2

I've just installed .NET 4 on Windows SErver 2008 R2 x64 and I am getting 500 Internal Server Error with an ASP.NET MVC application which was previously running fine on 3.5. 我刚刚在Windows SErver 2008 R2 x64上安装了.NET 4,并且我使用ASP.NET MVC应用程序获得了500内部服务器错误,该应用程序以前在3.5上运行正常。 The application was upgraded from targeting 3.5 to target 4 and I personally built it today on my development machine (changed in VS - Properties to .NET Framework 4). 该应用程序已从目标3.5升级到目标4,我今天在我的开发机器上进行了个人构建(在VS中更改 - 属性到.NET Framework 4)。

On the server I installed .NET Framework 4 Client profile and Full both automatically through the Web Platform Installer. 在服务器上,我通过Web Platform Installer自动安装了.NET Framework 4 Client profile和Full。 ASP.NET MVC 2 was also installed through Platform Installer. ASP.NET MVC 2也通过Platform Installer安装。 I created a new .NET 4 application pool in IIS and placed the web app in it. 我在IIS中创建了一个新的.NET 4应用程序池,并将Web应用程序放入其中。

Also I have custom errors turned Off in web.config but even so no detailed error is displayed - just the plain IIS 7.5 500 Internal Server Error. 此外,我在web.config中关闭了自定义错误,但即使这样也没有显示详细错误 - 只是普通的IIS 7.5 500内部服务器错误。

Any suggestions? 有什么建议?

Well, that's a very strange and interesting issue.. But I'm eager to help as much as I can. 嗯,这是一个非常奇怪和有趣的问题..但我渴望尽可能多地提供帮助。 I've currently got a VPS with Server 2008 R2, and I've installed .NET 4 RTM, and MVC 2 on it. 我目前使用Server 2008 R2获得了VPS,并且我已经安装了.NET 4 RTM和MVC 2。 Don't think I've run into configuration issues, but I have had to help set up some other people with it.. 不要以为我遇到了配置问题,但我不得不帮助设置其他人。

Initially, could you check.. in your IIS manager, Isapi and Cgi restrictions, do you have .NET 4 in there? 最初,您可以检查..在您的IIS管理器,Isapi和Cgi限制,你有.NET 4吗? Which versions? 哪个版本? are they enabled? 他们启用了吗?

If you go to your app pools in IIS, are your app pools ser to .NET 4, the NEW version? 如果您转到IIS中的应用程序池,您的应用程序池是否已服务于.NET 4,即新版本? Double check this, your app pools might be set to a different build of the .NET 4 framework, that has since been removed / disabled. 仔细检查一下,您的应用程序池可能被设置为.NET 4框架的不同版本,此后已被删除/禁用。 You can try create a NEW website with a new clean app pool just to test if it works. 您可以尝试使用新的干净应用程序池创建一个新网站,以测试它是否有效。

If nothing works yet, you can try to re-register .NET in IIS with aspnet_regiis -i 如果还没有任何工作,您可以尝试使用aspnet_regiis -i在IIS中重新注册.NET

If none of these work, I'll try to come back with some more options/ideas 如果这些都不起作用,我会尝试回来提供更多选项/想法

I usually solve that kind of problem by reinstalling the ASP.NET support files on the IIS. 我通常通过在IIS上重新安装ASP.NET支持文件来解决这类问题。

  1. Open a command prompt with admin privileges (Command Prompt, right-click, Run as Administrator) 使用管理员权限打开命令提示符(命令提示符,右键单击,以管理员身份运行)
  2. Type in: 输入:

    cd %WINDIR%\\Microsoft.NET\\Framework64\\v4.0.XX.XX

    aspnet_regiis -i

Done. 完成。 You might need to open IIS and reassign your application pools to the newly created "ASP.NET 4.0 Integrated" (or Classic). 您可能需要打开IIS并将应用程序池重新分配给新创建的“ASP.NET 4.0集成”(或Classic)。

I have also small compatibility problems with my ASP.NET MVC application. 我的ASP.NET MVC应用程序也存在小的兼容性问题。 It can be you have the same problem. 它可能是你有同样的问题。

I used NoSessionControllerFactory to disable SessionState based of How can I disable session state in ASP.NET MVC? 我使用NoSessionControllerFactory来禁用基于如何在ASP.NET MVC中禁用会话状态的 SessionState and http://billrob.com/archive/2009/07/15/asp-net-mvc-without-sessionstate.aspx . http://billrob.com/archive/2009/07/15/asp-net-mvc-without-sessionstate.aspx After updating to .NET 4.0 my application didn't work. 更新到.NET 4.0后,我的应用程序无法正常工作。 I received also 500 Internal Server Error. 我还收到了500内部服务器错误。 After small modification of NoSessionControllerFactory from Global.asax.cs the world was OK. 在从Global.asax.csNoSessionControllerFactory进行小修改后,世界就可以了。 The fixed code looks like following: 固定代码如下所示:

public class NoSessionControllerFactory: DefaultControllerFactory {
    protected override IController GetControllerInstance (RequestContext requestContext, Type controllerType) {
        if (controllerType != null) {
            var controller = base.GetControllerInstance (requestContext, controllerType);
            ((Controller)controller).TempDataProvider =
                new DummyTempDataProvider ();
            return controller;
        }
        else
            return null;
    }
}
public class DummyTempDataProvider: ITempDataProvider {
    public IDictionary<string, object> LoadTempData (ControllerContext controllerContext) {
        return new Dictionary<string, object> ();
    }
    public void SaveTempData (ControllerContext controllerContext,
        IDictionary<string, object> values) {
    }
}

The class will be used inside of Global.asax.cs like: 该类将在Global.asax.cs中使用,如:

protected void Application_Start () {
    RegisterRoutes (RouteTable.Routes);

    // see https://stackoverflow.com/questions/884852/how-can-i-disable-session-state-in-asp-net-mvc
    ControllerBuilder.Current.SetControllerFactory (new NoSessionControllerFactory ());
}

I bet that it is a configuration issue with the application in question. 我敢打赌,这是有问题的应用程序的配置问题。 ASP.NET 4's configuration differs from 3.5's. ASP.NET 4的配置与3.5不同。

And also, make sure that your web application references the DLL's from .NET 4, and not .NET 3.5. 此外,请确保您的Web应用程序从.NET 4引用DLL,而不是.NET 3.5。

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

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