Click here to Skip to main content
16,007,760 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I wonder if there is any difference in handling url in the MVC and Web Forms, I am new to this and want to create a table where I store the routes of the menus to be complatible with Web Forms and MVC but MVC with UrlAction () I can pass the driver name and the action and ready I have no problem of missing me put the name of the virtual directory and stuff, but I have no experience in web forms and I'm not sure if this feature may work for me by I see that the paths in html web forms puts forward several ellipses also the programming paradigm is different
Posted

1 solution

ASP .NET URL Routing:
C#
protected void Application_Start(object sender, EventArgs e)
{
    RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("",
        "Category/{action}/{categoryName}",
        "~/categoriespage.aspx");
}


MVC URL Routing:
C#
public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

    }

    protected void Application_Start()
    {
        RegisterRoutes(RouteTable.Routes);
    }
}

Always good to read the documentation[^] first. :)

-KR
 
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