Click here to Skip to main content
15,896,410 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using ASP.NET MVC 5.2.2.0 (C#) within Webform.
When I follow this step:
HTML
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:
HTML
right click Views\Home folder -> Add -> Web form -> ok


In HomeController.cs
C#
public ActionResult Test()
{
return View("webform2");
}


In RouteConfig.cs
C#
public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{WebForm}.aspx/{*pathInfo}");
            routes.MapRoute(
                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:
HTML
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!
Posted
Updated 24-Apr-15 10:05am
v2

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