0

I'm using ASP.NET MVC 5.2.2.0 (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)
        {
            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:

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!

  • why you're using a webform in a mvc application and why not using a .cshtml view file for the controller function instead of using webforms? – Khairul Islam Apr 24 '15 at 20:57
  • because I want to use some server controls like: panel and gridview. it's easy to use by webform. –  Apr 24 '15 at 22:47

1 Answers1

0

By default Views folder have web.config file that blocks access to all items in that folder an below.

Fix:

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179