Kevin Montrose
Kevin Montrose

Reputation: 22571

Moving an ASP.NET project to .NET 4

I'm moving an ASP.NET project from .NET 3.5 to .NET 4.

Everything works beautifully if I'm debugging under web.dev (ie. in Visual Studio [2010]) but as soon as I try and run this under IIS7[.5] the debugger fails to attach. Running the project directly under IIS just causes it to throw back 403s (no subcode, so not much help there).

I setup the site by taking the current (and working!) .NET 3.5 site, and changing the AppPool to one with the .NET 4 runtime. I've confirmed that all file permissions are kosher (at least from the .NET 3.5 perspective). I feel as though I'm missing some configuration step here...

The error message when trying to attach the debugger is just "Unable to start debugging on the webserver." Not the most useful error message in the world.

Directly attaching to the associated w3wp process strongly suggests that the application is never spun up successfully.

The basic question is, how would I affect this change over from .NET 3.5 to .NET 4 for a project running under IIS?

Upvotes: 6

Views: 510

Answers (4)

Brandon Luhring
Brandon Luhring

Reputation: 61

IIS7 has two options within a "website". In IIS6 you'd add a sub-app as a "Add Virtual Directory..." in IIS7 doing so forces you to keep the same AppPool and thus .NET framework version as the website.

But, IIS7 now has an "Add Application..." options, which allows you to essentially do what IIS6 had allowed, so that you can explicitly state the AppPool to run in and it can differ from the parent website.

Upvotes: 1

Kevin Montrose
Kevin Montrose

Reputation: 22571

Figured it out.

.NET 4 had not been installed for IIS purposes. Don't ask me why that was the case.

Running asp_net_regiis -i in the .NET 4 install directory (\Windows\Frameworks\v4.0.xxxx) under the Visual Studio Command Prompt (x64 in my case) solved the problem.

Upvotes: 4

Philip Smith
Philip Smith

Reputation: 2801

You cannot mix .NET frameworks in the same app pool. So ensure that only .NET 4.0 web sites are in your app pool.

Remember to set the web site/virtual directory to .NET 4 as well.

Upvotes: 2

Carter Medlin
Carter Medlin

Reputation: 12465

Start a fresh project from scratch and just use the web.config there. Copy all your 3.5 pages in there and manually move over web.config elements that you need. The pages themselves don't require any converting, it's all in the web.config. The web.config for a .net 4.0 page is actually significantly smaller due to the fact that .net 4.0 is not just an extension of .net 2.0 like 3.5 is.

Upvotes: 0

Related Questions