daustin
daustin

Reputation: 623

How do I use ASP.NET MVC 3 in an ASP.NET Website project?

I am trying to get ASP.NET MVC 3 to work on an ASP.NET website project (NOT web application) project that uses WebForms. I have a test page "working". The only issue is within the view when I am in visual studio I get no intellisense and the following issue:

MVC 3 'ViewData' is not declared. It may be inaccessible due to its protection level.

I created an ASP.NET MVC 3 project and a website project and compared the web.config and had made sure to add all the correct references. System.Web.Mvc is referenced in my root web.config. What could I be doing wrong?

Upvotes: 0

Views: 283

Answers (1)

bhamlin
bhamlin

Reputation: 5187

MVC views are of type ViewPage. http://msdn.microsoft.com/en-us/library/system.web.mvc.viewpage.aspx

Webform pages are of type Page. http://msdn.microsoft.com/en-us/library/system.web.ui.page.aspx

They aren't related. You can't use them interchangably. What are you trying to accomplish? MVC and Webforms can coexist in the same site but they cannot work together like you're trying. MVC requires controllers that are compiled, you cannot use MVC in a runtime-compiled "website".

They handle requests in completely different ways.

Upvotes: 1

Related Questions