在MVC VS WEB.FORMS中处理url有什么区别 [英] What is the difference in handling url in MVC VS WEB.FORMS

查看:50
本文介绍了在MVC VS WEB.FORMS中处理url有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在MVC和Web窗体中处理url是否有任何区别,我是新手,并希望创建一个表,我将菜单的路由存储为Web Forms和MVC,但MVC与UrlAction()我可以传递驱动程序名称和操作并准备好我没有错过我把虚拟目录的名称和东西,但我没有网络表单的经验,我不知道这个功能是否可行对我来说,我看到html web表单中的路径提出了几个省略号,编程范例也不同

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

推荐答案

ASP .NET URL路由:

ASP .NET URL Routing:
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路由:



MVC URL Routing:

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);
    }
}



一定要好好阅读文档 [ ^ 首先。 :)



-KR


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

-KR


这篇关于在MVC VS WEB.FORMS中处理url有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆