[英]Rename ReturnUrl literal in asp.net mvc
I put the authentication attribute that sets: 我把认证属性设置为:
filterContext.Result = new HttpUnauthorizedResult();
so when I try to access 所以,当我尝试访问
http://www.mysite.com/Forum/Polls
and I am not authenticated I am redirected to: 我没有通过身份验证我被重定向到:
http://www.mysite.com/Account/Log?ReturnUrl=%2FForum%2FPolls
I want to have the following line instead: 我希望改为以下行:
http://www.mysite.com/Account/Log?back=%2FForum%2FPolls
, so instead of 'ReturnUrl' need 'back'. ,所以不要'ReturnUrl'需要'回'。 Where I can ovveride this behaviour.
我可以在哪里摆脱这种行为。 Thanks.
谢谢。
You can rewrite "ReturnURL" on EndRequest event. 您可以在EndRequest事件上重写“ReturnURL”。
This is sample code. 这是示例代码。
protected void Application_EndRequest()
{
if (Response.StatusCode != 301 && Response.StatusCode != 302) return;
var targetUrl = Response.RedirectLocation.Replace("ReturnUrl","back");
Response.RedirectLocation = targetUrl;
}
Hope this code. 希望这段代码。
It doesn't look like you can. 它看起来不像你。 That comes from
System.Web.Security.FormsAuthentication.GetLoginPage()
If you look at the code, you see that it is indeed a hard coded literal. 它来自
System.Web.Security.FormsAuthentication.GetLoginPage()
如果查看代码,您会发现它确实是一个硬编码的文字。 At least in System.Web version 2.0.0.0 至少在System.Web版本2.0.0.0中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.