如何在asp.net mvc中使用路由 [英] how routing works in asp.net mvc

查看:64
本文介绍了如何在asp.net mvc中使用路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码用于默认路线。



following code is for the default route.

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





--------------------------------



新到mvc,怀疑是没有添加一个控制器到routes.maproute也

控制器调用和行动正在调用。

你可以解释我们。

如何发生这种情况。



--------------------------------

new to mvc , doubt is with out adding a controller to routes.maproute also
controler is invoked and action is calling.
can you please explan me guys.
how this happening.

推荐答案

在mvc中调用默认控制器如果没有注册新的控制器。可视化工作室创建mvc项目的模板默认具有控制器文件夹,它具有为默认请求调用的索引操作方法。
The default controller is called in mvc if a new controller is not registered.The template through which visual studio creates mvc project has by default controller folder and it has the the index action method which is invoked for default requests.


这篇关于如何在asp.net mvc中使用路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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