ASP.NET MVC - HttpPost to ReturnURL after redirect
Posted
by JP
on Stack Overflow
See other posts from Stack Overflow
or by JP
Published on 2010-05-30T19:01:39Z
Indexed on
2010/05/30
19:22 UTC
Read the original article
Hit count: 1404
c#
|asp.net-mvc
Hello, I am writing an ASP.NET MVC 2.0 application which requires users to log in before placing a bid on an item. I am using an actionfilter to ensure that the user is logged in and, if not, send them to a login page and set the return url. Below is the code i use in my action filter.
if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
{
filterContext.Result = new RedirectResult(String.Concat("~/Account/LogOn","?ReturnUrl=",filterContext.HttpContext.Request.RawUrl));
return;
}
In my logon controller I validate the users credentials then sign them in and redirect to the return url
FormsAuth.SignIn(userName, rememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
My problem is that this will always use a Get (HttpGet) request whereas my original submission was a post (HttpPost) and should always be a post. Can anyone suggest a way of passing this URL including the HttpMethod or any workaround to ensure that the correct HttpMethod is used?
Thanks in advance,
JP
© Stack Overflow or respective owner