Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:34:56+00:00 2026-05-24T18:34:56+00:00

I am using the Ajax.BeginForm to create a form the will do an ajax

  • 0

I am using the Ajax.BeginForm to create a form the will do an ajax postback to a certain controller action and then if the action is successful, the user should get redirected to another page (if the action fails then a status message gets displayed using the AjaxOptions UpdateTargetId).

using (Ajax.BeginForm("Delete", null,
        new { userId = Model.UserId },
        new AjaxOptions { UpdateTargetId = "UserForm", LoadingElementId = "DeletingDiv" },
        new { name = "DeleteForm", id = "DeleteForm" }))
   {
    [HTML DELETE BUTTON]
   }

If the delete is successful I am returning a Redirect result:

[Authorize]
public ActionResult Delete(Int32 UserId)
{
    UserRepository.DeleteUser(UserId);
    return Redirect(Url.Action("Index", "Home"));
}

But the Home Controller Index view is getting loaded into the UpdateTargetId and therefore I end up with a page within a page. Two things I am thinking about:

  1. Either I am architecting this
    wrong and should handle this type of
    action differently (not using ajax).
  2. Instead of returning a Redirect
    result, return a view which has
    javascript in it that does the
    redirect on the client side.

Does anyone have comments on #1? Or if #2 is a good solution, what would the “redirect javascript view” look like?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:34:57+00:00Added an answer on May 24, 2026 at 6:34 pm

    You can use JavascriptResult to achieve this.

    To redirect:

    return JavaScript("window.location = 'http://www.google.co.uk'");
    

    To reload the current page:

    return JavaScript("location.reload(true)");
    

    Seems the simplest option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
I have a simple form created using Ajax.BeginForm : <% using (Ajax.BeginForm(Update, Description, new
In the following code, I'm using Ajax.BeginForm to post data to the action asynchronously.
I've got my form as follows <div id=contact-form class=hidden title=Online Request Form> @Using (Ajax.BeginForm(Contact,
I have a form created using Ajax.BeginForm() <% using (Ajax.BeginForm(UpdateCompanyShop, CompanyShop, FormMethod.Post, new AjaxOptions
I using this Ajax.BeginForm <% using( Ajax.BeginForm( Create,Mandate, new AjaxOptions( ) { OnSuccess =
I'm using jQuery UI dialog. I have a delete form as follows: @using (Ajax.BeginForm(DeleteUser,
In ASP.NET MVC 3, I've declared an ajax form like this: @using (Ajax.BeginForm(SaveRegistrationConfirmationRequest, null,
I am performing an Ajax submit ASP.Net with MVC : @using (Ajax.BeginForm( action, References,
I have an ajax form like so: <% using (Ajax.BeginForm(Comments, Comments, null, new AjaxOptions

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.