protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (Session["user"] == null) { string returnUrl = filterContext.HttpContext.Request.Url.AbsolutePath; filterContext.Result = Redirect("/Account/Login?ReturnUrl="+ returnUrl); } }
我写了一个Basecont带returnurl,我在login方法中
string returnurl = HttpContext.Request.QueryString["RetrunUrl"];
一直获取不到returnurl的值,求大神解答到底哪里错了
100分我拿了
string returnurl = HttpContext.Request.QueryString["ReturnUrl"];改了就好。ReturnUrl你写成RetrunUrl 了
将 Redirect 方法换成 RedirectResult 试一下
string returnurl = HttpContext.Request["RetrunUrl"];
这样写试试
filterContext.Result = RedirectToAction("login", "account", new RouteValueDictionary { { "ReturnUrl", returnUrl} });
get方法中才能获取 已解决
get方法中获取