在MVC VS WEB.FORMS中处理url有什么区别 [英] What is the difference in handling url in MVC VS WEB.FORMS
问题描述
我想知道在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);
}
}
Always good to read the documentation[^] first. :)
-KR
这篇关于在MVC VS WEB.FORMS中处理url有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!