15

I need to add an "Admin" Area to an ASP.NET MVC project, and I need it to use ASP.NET Web Forms, not MVC.

Can ASP.NET Web Forms be used in an ASP.NET MVC application?

2 Answers 2

17

I have something similar in an MVC project because we had to use some 3rd party controls on a page. So what we did was this:

In the RegisterRoutes in global.asax.cs add:

routes.IgnoreRoute("WebForms/*/{resource}.aspx/{*pathInfo}");

And add your webforms stuff to the WebForms directory (obviously you can change that to whatever you need, so long as it doesn't clash with any of your MVC routes.

I think that was about it. Other than being a really horrible kludge.

Sign up to request clarification or add additional context in comments.

2 Comments

Is the webforms folder supposed to be in the Views folder or in the app's root folder. I tried both and then tried accessing the aspx page (i.e. foo.aspx) like this: "localhost/foo", "localhost/foo.aspx", etc. and it didn't work. I'm sure I'm missing something trivial.
No. The WebForms folder is not in the Views folder. It is on the root of the website. (You can, of course, put it anywhere you like, but you'll have to adjust the IgnoreRoute method call)
7

It is possible to mix ASP.NET WebForms and MVC in the same project. Scott Hanselman had a post about this back in 2008:

Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.