在ASP.NET MVC 中获取当前URL、controller、action
来源:互联网 发布:linux返回根目录命令 编辑:程序博客网 时间:2024/05/04 18:07
URL的获取很简单,ASP.NET通用:
【1】获取 完整url
(协议名+域名+虚拟目录名+文件名+参数)
string url=Request.Url.ToString();
【2】获取 虚拟目录名+页面名+参数:
string url=Request.RawUrl;
(或 string
url=Request.Url.PathAndQuery;)
【3】获取
虚拟目录名+页面名:
string url=HttpContext.Current.Request.Url.AbsolutePath;
(或
string url= HttpContext.Current.Request.Path;)
【4】获取 域名:
string
url=HttpContext.Current.Request.Url.Host;
【5】获取 参数:
string url=
HttpContext.Current.Request.Url.Query;
【6】获取 端口:
Request.Url.Port
二、当前controller、action的获取
RouteData.Route.GetRouteData(this.HttpContext).Values["controller"]
RouteData.Route.GetRouteData(this.HttpContext).Values["action"]
或
RouteData.Values["controller"]
RouteData.Values["action"]
如果在视图中可以用
ViewContext.RouteData.Route.GetRouteData(this.Context).Values["controller"]
ViewContext.RouteData.Route.GetRouteData(this.Context).Values["action"]
或
ViewContext.RouteData.Values["controller"]
ViewContext.RouteData.Values["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 中获取当前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 中获取当前URL、controller、action
- MVC中获取当前URL、controller、action
- ASP.NET MVC 中 当前controller、action的获取
- MVC下在控制器与试图中获取当前页面的URL与controller、action
- .net mvc 获取url中controller和action
- .net mvc 获取url中controller和action
- .net mvc 获取url中controller和action
- Java总结篇系列:Java泛型 转自 Corn
- SpringMVC学习笔记之SpringMVC的架构原理图
- Tab 选项卡
- Cocoapods 执行不同的版本,安装多个版本
- 自定义类加载器(实现加密和解密)
- 在ASP.NET MVC 中获取当前URL、controller、action
- 解决Easyui Tab href 加载对话框中form重复提交问题
- Ubuntu命令行启动Matlab
- Java StringBuffer 用法
- ecshop二次开发--放大镜
- 手把手教你搞懂麦克风的技术指标
- intent.setAction的介绍
- 机器学习笔记2——分类
- 百度登录加密协议分析(下)