Click here to Skip to main content
15,792,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using ASP.NET MVC (C#) within Webform.
When I follow this step:
right click solution -> Add -> New item -> create new webform

After debugging, that's work without a problem when I type "localhost/webform1.aspx" on url.
But, when I do this:
right click Views\Home folder -> Add -> Web form -> ok

In HomeController.cs
public ActionResult Test()
return View("webform2");

In RouteConfig.cs
public static void RegisterRoutes(RouteCollection routes)
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

It gave to me an error when I type "localhost/home/test" on url:
The view at '~/Views/home/webform2.aspx must derive from ViewPage, ViewPage<TModel>...'

My question is: Can't webform be created in Views\Home folder?
If possible, can you tell me how to do that?

Thank you!
Updated 24-Apr-15 11:05am

1 solution

You can't mix and match MVC controllers and webforms. If you want to use a webform place it outside of the views folder and access it direct, not via a controller. The Views folder is where MVC looks for MVC views.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900