ASP.NET MVC4 with webforms Default.aspx as the start page

nam

I had an ASP.NET MVC4 app with the following routing defined in the Global.asax.cs. The app's start page is Index.cshtml view that is returned from the action method Index() of the Home controller. I then added a legacy ASP.NET WebForms app that had Default.aspx as the start page. How can I make this Default.aspx page as the start page of this integrated MVC+WebForms app:

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default",
                "{controller}.mvc/{action}/{id}",
                new { action = "Index", id = "" }
              );


              routes.MapRoute(
              "Root",
              "",
              new { controller = "Home", action = "Index", id = "" }
            );


        }
Brent Mannering

Try the following in your Global.asax:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    // Web Forms default
    routes.MapPageRoute(
        "WebFormDefault",
        "",
        "~/default.aspx"
    );

    // MVC default
    routes.MapRoute(
        "Default",                          // Route name
        "{controller}/{action}/{id}",       // URL with parameters
        new { controller = "Home", action = "Index", id = UrlParameter.Optional }  // parameter default
    );
}

Also I don't think you'll need the .mvc portion of the Default route.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Routing to an aspx page on a project with webforms and MVC

From Dev

ASP.net default login.aspx page missing images

From Dev

asp.net webforms access nested properties from .aspx

From Dev

asp.net webforms access nested properties from .aspx

From Dev

MVC and aspx - setting the default page

From Dev

Async Page Asp.net webforms threads

From Dev

ASP.NET MVC4 with ASPX Render Engine: Fill src attribute dynamically

From Dev

Create a form on an ASPX page in asp.net

From Dev

ASP.NET: Call .swf in .aspx page

From Dev

Regex not working in asp.net(.aspx page)

From Dev

Isn't ASP.NET MVC _layout.cshtml similar to Webforms Master page?

From Dev

Gravatar in ASP.Net WebForms showing default image

From Dev

How to run Asp.net Webforms Website with MVC 4 application

From Dev

What methods are executed in which order in this ASP.NET webforms page

From Dev

ASP.NET WebForms - How to Authorise access to a page

From Dev

ASP.net WebForms - Constructor vs. Page_Load

From Dev

Open specific tab on another page with ASP.NET Webforms

From Dev

Need to design html page for Thermal Printer in asp.net webforms

From Dev

ASP.NET WebForms - How to Authorise access to a page

From Dev

Refresh part of page after successful user sign in (ASP.NET MVC4)

From Dev

React - MVC4 .Net - Blank page

From Dev

How to change default page in ASP.NET MVC

From Dev

ASP.NET MVC routing aspx file

From Dev

ASP.NET Web Application Does not Autoredirect to Default.aspx

From Dev

asp.net forms authentication occasionally redirects to default.aspx

From Dev

Routing ASP.NET MVC4

From Dev

ASP.NET MVC4 ActionFilters

From Dev

JSON in ASP.NET MVC4

From Dev

Routing in Asp.Net MVC4

Related Related

HotTag

Archive