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 6131897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:02:04+00:00 2026-05-23T17:02:04+00:00

I have a form which can contain files and it shows a progress bar

  • 0

I have a form which can contain files and it shows a progress bar successfully. My problem is that in the MVC Controller I have:

return RedirectToAction("Complete", new { title = title });

This goes and executes the Complete method if I step through but it then goes back to the JavaScript load event and does not redirect me unless I add a JavaScript redirect in the load event listener (uploadComplete):

var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.open("POST", "/Submit-Recipe", true);
xhr.send(fd);

function uploadComplete(evt) { 
//var valueFromController = how do I get a value here?;       
//window.location.replace("http://@ConfigurationManager.AppSettings["website"]/SubmitRecipeComplete/" + valueFromTheController);
}

Is there a way to not have to add a JavaScript redirect? If I do need a JavaScript redirect, how can I pass a variable back from the controller when it needs to be an ActionResult (for if there is an error and I need to redisplay the page?).

I can work around this by adding a second page where I could know the “valueFromController” but 2 forms breaks the workflow a bit.

EDIT

I did what Praveen said but GetData() did not work for me so I used this instead:

evt.currentTarget.responseText 

To determine if to return the View or Content I added this just before xhr.send(fd);

xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

In the controller I can then do:

if (Request.IsAjaxRequest())
{
    return Content(title);
}     
  • 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-23T17:02:04+00:00Added an answer on May 23, 2026 at 5:02 pm
    public Class myContoller:controller
    {
         public ActionResult MyAction()
         {
         bool isWantToRedirect;
    
         if(isWantToRedirect)
         {
           return Content('redirect');
         }
         else
         {
              return View(); 
         }
    }
    
    
    
    function uploadComplete(evt) { 
    
     var valueFromController = evt.GetData();
    
      if(valueFromController=="redirect")
      {
         //redirect
      }
      else
      {
         //do not redirect, do something else
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in which the user can choose a component type from
In WinForms, I can design a form and have a TabValue to control which
I have a form which is used to insert/display and update . In the
I have a form which takes both the user details and an image uploaded
I have a form which has a lot of SELECTs. For various reasons, I'd
In my Rails app, I have a form which redirects through a foreign service,
I have a form in which people will be entering dollar values. Possible inputs:
I have a C# form into which I've placed a left-docked MenuStrip . This
I have a an HTML form which contains the YAHOO rich text editor on
I have CustomForm inherited from Form which implements a boolean property named Prop .

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.