Share via


Add aspx page to MVC application

Question

Tuesday, November 27, 2012 11:54 PM

How to add aspx page to existing MVC3 application?

Thanks

All replies (6)

Wednesday, November 28, 2012 7:10 AM âś…Answered

You don't need to add a special route to add a webforms .aspx page to your MVC applications. Just add the file and it will work as long as you don't put it in the Views folder.

You cannot put the webforms .aspx file in the views folder, it won't work if it's there due to settings in web.config. The way to make it work is to simply create a folder on your project root and call it "WebForms" (or anything else you like, I use WebForms) and put the .aspx webforms in there.

I have done this many times and it works just fine.


Tuesday, November 27, 2012 11:59 PM

How to add aspx page to existing MVC3 application?

Try as:

http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx


Wednesday, November 28, 2012 12:06 AM

Just add to the project.

But why do you need this?


Wednesday, November 28, 2012 12:30 AM

I added  routes.MapPageRoute("WebFormProducts", "WebForm1", "~/WebForm1.aspx"); to global.asax.cs.

gives an error

The resource cannot be found.


Wednesday, November 28, 2012 1:57 AM

routes.MapPageRoute("WebFormProducts", "WebForm1", "~/WebForm1.aspx");

Why you need routing in MVC for WebForms? Just go to that page directly.


Wednesday, November 28, 2012 4:47 AM

I tried to access it directly. please see below image for result page

http://heartyweb.com/Untitled3.jpg