I would like to have different ReturnUrl
for certain action in my ASP.NET MVC controller. Controller have Authorize attribute and OnEndRequest
handler do the work for adding ReturnUrl
to not authorized requests like so:
protected override void OnEndRequest(object sender, EventArgs args)
{
HttpApplication app = (HttpApplication)sender;
var location = resp.RedirectLocation;
...
}
Then location
will be used as value for ReturnUrl
parameter.
The question: Is it possible, in some elegant way like some attribute on action, substitute value in resp.RedirectLocation
or do it in different way?
Thanks.
You can send your return url to your custom Authorize attribute
public class AuthAttribute:ActionFilterAttribute
{
private string _returnUrl { get; set; }
public AuthAttribute(string url)
{
_returnUrl = url;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.