检查当前请求是否来自httpmodule中的mvc页面
问题描述:
是MVC的新手我有一个问题。在http模块中,如何查找当前请求是否来自mvc页面,例如http://www.website.com/user/edit检查当前请求是否来自httpmodule中的mvc页面
我可以检查当前上下文中是否有某些内容?
答
你可以在控制器和动作名称....
var request = httpContext.Request.RequestContext.RouteData.Values;
string ActionName = request["Action"].ToString();
string ControllerName = request["Controller"].ToString();
+0
根据你想去的地方要使用此代码,您可能需要知道完整的namesapce,它是:System.Web.HttpContext.Current.Request.RequestContext.RouteData.Values – 2013-05-23 05:13:20
答
你可以尝试使用引用属性
if(Request.UrlReferrer != null
&& Request.UrlReferrer.PathAndQuery.StartsWith("/User/Edit/"))
{
return View("SomeOtherView");
}
是帮助全... – 2012-04-26 13:32:06