views:

1367

answers:

5

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. 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).

On the server I installed .NET Framework 4 Client profile and Full both automatically through the Web Platform Installer. ASP.NET MVC 2 was also installed through Platform Installer. I created a new .NET 4 application pool in IIS and placed the web app in it.

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.

Any suggestions?

A: 

I'm having the same problem. I installed the full .NET 4.0 RC framework on a Windows Server 2008 R2 x64. I have 2 different ASP.NET MVC2 apps and both just return 500. Both apps work fine on a Window Server 2008 32-bit (non R2), and on the Windows 7 x64 dev box. I have tried remote-debugging the apps but it's not even hitting any of my code

Dan Suceava
Yeah, my server box is also x64. I also tried compiling specifically for x64 and Any Cpu but with no change to the behaviour.
mare
+3  A: 

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. 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? 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? Double check this, your app pools might be set to a different build of the .NET 4 framework, that has since been removed / disabled. 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

If none of these work, I'll try to come back with some more options/ideas

Artiom Chilaru
+1  A: 

I usually solve that kind of problem by reinstalling the ASP.NET support files on the IIS.

  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).

Fábio Batista
My configuration is fine and I have the new ASP.NET 4 app pools. The problem is that I'm running my app in virtual directory and there seems to be something wrong with Web.Config inheritance.I just tested creating a new root website in IIS and putting it into .NET 4 Integrated app pool and it works fine.
mare
A: 

I have also small compatibility problems with my ASP.NET MVC application. It can be you have the same problem.

I used NoSessionControllerFactory to disable SessionState based of http://stackoverflow.com/questions/884852/how-can-i-disable-session-state-in-asp-net-mvc and http://billrob.com/archive/2009/07/15/asp-net-mvc-without-sessionstate.aspx. After updating to .NET 4.0 my application didn't work. I received also 500 Internal Server Error. After small modification of NoSessionControllerFactory from Global.asax.cs the world was OK. 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:

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

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

I bet that it is a configuration issue with the application in question. ASP.NET 4's configuration differs from 3.5's.

And also, make sure that your web application references the DLL's from .NET 4, and not .NET 3.5.

Venemo