如果在MVC中不存在路由,会发生什么?在MVC中路由的重要性是什么? [英] What Happens if routing is not there in MVC ? What is the Importance of Routing in MVC ?

查看:93
本文介绍了如果在MVC中不存在路由,会发生什么?在MVC中路由的重要性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在MVC中没有路由,会发生什么?在MVC中路由的重要性是什么?

What Happens if routing is not there in MVC ? What is the Importance of Routing in MVC ?

推荐答案

路由是ASP.NET MVC的一个重要且重要的特性。



在接下来的两篇文章中,您可以找到有关路由问题的详细解答:

MVC中的路由 [ ^ ]

自定义ASP.NET MVC中的路由 [ ^ ]
The routing is an important and "vital" feature of ASP.NET MVC.

In the next two articles you can find detailed answers to your question about routing:
Routing in MVC [^]
Customizing Routes in ASP.NET MVC[^]


路由是webapplication中的起始页面。



如果你设置是你的起始页面,你将更改控制器名称而不是主页





routing is starting page in webapplication.

If you set about is your starting page you will change controller name About instead of Home


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

     routes.MapRoute(
         name: "Default",
         url: "{controller}/{action}/{id}",
         defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
     );
 }





更改:默认值:new {controller =关于,action =Index,id = UrlParameter.Optional}



Changed: defaults: new { controller = "About", action = "Index", id = UrlParameter.Optional }


这篇关于如果在MVC中不存在路由,会发生什么?在MVC中路由的重要性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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