MVC View中获取action、controller、area名称、参数
来源:互联网 发布:淘宝如何合并订单 编辑:程序博客网 时间:2024/05/23 01:17
转载地址: http://www.cnblogs.com/xcsn/p/3490543.html
获取控制器名称:
ViewContext.RouteData.Values["controller"].ToString();
获取Action名称:
ViewContext.RouteData.Values["action"].ToString();
获取路由参数值:
ViewContext.RouteData.Values[名称].ToString();
如:ViewContext.RouteData.Values["ID"].ToString(); 获取ID的值
获取area名称
在代码中:
ControllerContext.RouteData.DataTokens["area"]
在View中:
ViewContext.RouteData.DataTokens["area"]
具体代码
var action = ViewContext.RouteData.Values["Action"].ToString().ToLower();
var controllerName = ViewContext.RouteData.Values["controller"].ToString().ToLower();var areaName = ViewContext.RouteData.DataTokens["area"].ToString().ToLower();
var modalID = Request["ModalID"];//举例,url如 edit?modalid=1
0 0
- MVC View中获取action、controller、area名称、参数
- MVC View中获取action、controller、area名称
- MVC View中获取action、controller、area名称
- MVC中获取当前URL、controller、action
- MVC中如何获取当前action、controller
- Asp.Net MVC 中获取Controller, Action 和参数的值
- 获取当前URL、area、controller、action
- .net mvc 获取url中controller和action
- 在ASP.NET MVC 中获取当前URL、controller、action
- .net mvc 获取url中controller和action
- 在ASP.NET MVC 中获取当前URL、controller、action
- 在ASP.NET MVC 中获取当前URL、controller、action
- 在ASP.NET MVC 中获取当前URL、controller、action
- 在ASP.NET MVC 中获取当前URL、controller、action
- 在ASP.NET MVC 中获取当前URL、controller、action
- ASP.NET MVC 中 当前controller、action的获取
- 在ASP.NET MVC 中获取当前URL、controller、action
- 在ASP.NET MVC 中获取当前URL、controller、action
- 用户名+密码登录ldap服务器,注意密码没有存储在ldap中的password
- 小白的代码审计之路(一)
- iOS模拟器simuator无法响应
- 射频识别技术漫谈(29)——射频接口芯片TRF7960
- HTML5本地存储——IndexedDB入门
- MVC View中获取action、controller、area名称、参数
- 漫画赏析:Linux 内核到底长啥样
- bat批处理文件中文乱码
- 音视频相关知识总结
- Struggle_1 个人项目展示
- ChemDraw怎么画3D图?
- 欢迎使用CSDN-markdown编辑器
- js和java中string的长度length
- php 5.0 与7.0有什么区别新增加匿名类。