AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
MVC version of Response.Redirect() in partial views
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
I am struggling to figure out how to redirect the user to a different page from within a controller. I created a partial view with the RegisterWidget[] decorator in the controller so the CMS will pick it up. I build a new inner template and add my widget. Then I set up a content page and assign to my inner template. All of this works great. The url renders, my GET method fires and I populate the model. Page works exactly like I need it. The problem starts when I set up a form that does a POST back to the controller. I need to pull in my page model properties, populate the class object and save. That all works. At the end of the postback, I want to redirect the user to a different place. For example, the home page. I can't figure out how to redirect at the end of the POST method. I've tried copying examples I've found elsewhere in Able, nothing works. All it does is render the actual javascript instead of executing it. Here's my form: Code:
@using (Html.BeginForm("Proceed", "RegisterInvitee", FormMethod.Post))
{
@Html.AntiForgeryToken()
<p>
As a non-US Citizen, no further details are required.
</p>
@Html.HiddenFor(model => model.Email)
<input type='Submit' value='Proceed To Welcome Page' class="btn btn-primary" />
}
Here's the method: Code:
[AllowAnonymous]
[HttpPost]
[ValidateAntiForgeryToken]
public JavaScriptResult Proceed(RegisterInviteeModel model)
{
// pull up user specified in model
User u = _userRepo.LoadForUserName(model.Email);
if (u != null)
{
// user object exists, update address profile
Address address = u.PrimaryAddress;
// set address flag based on citizenship
address.Residence = false;
_addressRepo.Save(address);
// authenticate this user account into Able
FormsAuthentication.SetAuthCookie(model.Email, false);
}
// we're done, dump user to home page
//return PartialView("_RegisterInvitee", model);
return JavaScript(string.Format(" window.location = '{0}' ", Url.Content("~/")));
}
Here is all I see when the method ends with the redirect Capture.JPG (17kb) downloaded 0 time(s).
|
|
|
|
Rank: Advanced Member
Groups: HelpDesk, Developers Joined: 11/9/2018(UTC) Posts: 564
Thanks: 122 times Was thanked: 26 time(s) in 25 post(s)
|
Apparently this works when using ActionResult as the return type. Mucho thank you to Joy @ Web2Market for the help! Code:
return RedirectToLocal("~/Account");
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
General Questions
»
MVC version of Response.Redirect() in partial views
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close