Patrick
Patrick

Reputation: 5592

IIS 7, MVC 3 and WebSite/WebApplication problem - Updated: 2011-04-21

Solved using this post: Can you convert an ASP.NET MVC Application to a Web Site using ASP.NET MVC and what problems might you run into?

EDIT: 2011-apr-21 (Got rid of the previous code to make it easier to read, some responses and comments are from the old post)

So i am trying to get my new MVC 3 page to work with IIS 7.

Here are the steps that i have taken so far:

IIS:

1) Create a new website in IIS 7 and set it to use .NET 4.0 (Integrated mode)

WebSite:

1) I just installed the new VS 2010 and MVC 3 (3 days ago), the MVC 3 i downloaded 3 days ago from asp.net/mvc.

2) I created a new MVC 3 project, File->New Project->Asp.Net MVC 3 Web Application.

Now i publish the project to a file path (like c:\project\newtestmvcapp

3) I upload the entire contents of the folder (newtestmvcapp) and poff it works.

I now remove the files from the domain.

4) I upload the normal files thats in the project path. I upload all folders except Bin, Obj and properties.

5) I run the page and now i get the following error: Could not load type 'MvcApplication1.MvcApplication'. <%@ Application CodeBehind="Global.asax.cs" Inherits="MvcApplication1.MvcApplication" Language="C#" %>

6) I change the CodeBehind to CodeFile and i get the following error: Missing partial modifier on declaration of type 'MvcApplication1.MvcApplication'; another partial declaration of this type exists. public class MvcApplication : System.Web.HttpApplication

7) I change this: public class MvcApplication : System.Web.HttpApplication , into this: public partial class MvcApplication : System.Web.HttpApplication

8) Now i just get an error that the resource (ex. Index can't be found or about or any other page) If i upload a test.htm it works, if i upload a forms page test.aspx it works. Just not the MVC.

EDIT: I found some article about the difference between a WebSite and a WebAppplication. Could that be the reason? If so, how can i change this MVC 3 project to be a website (thus allowing the project to be compiled at runtime). There isn't a File->New Web Site->MVC 3 Website in VS2010.

We want to be able to just upload a new view or a controller to the server and the server should then compile it for us. (Test/Dev server).

Upvotes: 0

Views: 4191

Answers (3)

Mike van der Eerden
Mike van der Eerden

Reputation: 11

I just wrote a blogpost 'bout this issue, although it's more about integrating MVC3 in a existing WebSite Project the same rules apply. You should be able to convert your WebApplication to a Website by right clicking the project in VS, there should be an option to convert in the menu. To get MVC3 running in a WebSite Project just put the Controllers and Models-folder under App_Code.

Upvotes: 1

DaNe505
DaNe505

Reputation: 71

Try this:

Open command prompt as administrator and insert the following text:

If you are using a 32bit machine: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i"

For 64bit machine: "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i"

If that doesn't work try this:

Right-click the System.Web.Routing reference, go to properties and set CopyLocal to true.

Hope this helps.

Upvotes: 0

Sergi Papaseit
Sergi Papaseit

Reputation: 16204

This:

In VS2010, i get the following red underlined "UrlRoutingModule" in add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"

Seems to point out you're using the System.Web.Routing dll of .NET 3.5.

Since you're building an MVC 3 app, am I right in assuming you're using .NET 4? If so, this appears to indicate that you're referencing the wrong version of System.Web.Routing.

Was this by any chance an MVC 2 app that you converted to MVC 3?


NOTE

This answer is massively edited and has nothing to do with my original answer. I point this out because @Patrick's comment to my answer could be confusing.

Upvotes: 0

Related Questions