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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:11:20+00:00 2026-06-11T19:11:20+00:00

In my ASP.NET MVC 3 application, I have an action that is triggered through

  • 0

In my ASP.NET MVC 3 application, I have an action that is triggered through a jQuery AJAX POST request. In this action, I check some DB data with the attributes, and if it passes the validation, I return a PartialView result that is set inside a div on the view in the success callback of the jQuery request. What I want to do is, if it does not pass validation, fully redirect the user to another page in my application.

I know I could do this through Javascript by passing a value to the view, and doing an extra check there, but I would like to know if it can be done on server-side.

  • 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-06-11T19:11:21+00:00Added an answer on June 11, 2026 at 7:11 pm

    In your contorller action you could return either a PartialView or a JsonResult pointing to the controller action to redirect to:

    public ActionResult SomeAction()
    {
        if (HasPassedValidation)
        {
             // everything went fine => let's return a partial view
             // that will be updated
             return PartialView();
        }
    
        // something went wrong with the validation => 
        // we return a JsonResult pointing to the controller
        // action we want to redirect to
        var result = new 
        { 
            redirectTo = Url.Action("SomeOtherAction", "SomeController") 
        };
    
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    

    and then inside the success callback of your AJAX call test in which case you are and take respective steps:

    success: function(result) {
        if (result.redirectTo) {
            // the controller action returned a JSON result => there was an error
            // => let's redirect
            window.location.href = result.redirectTo;
        } else {
            // everything went fine => let's update the DOM with the partial
            $('#results').html(result);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC 3 application which has a post action called Create
I am using ASP.NET MVC with jQuery. I have the following MVC Action that
In an ASP.NET MVC application I have a CartController with this AddToCart action: public
I have an ASP.NET MVC application that uses jQuery 1.3.2. On several of the
I have an ASP.NET MVC 3 application with an action that uses both the
In my ASP.NET MVC application I have an action that returns LESS variables. I
I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This
In my ASP .NET MVC application i have a link that refreshes the preview
I have an ASP.NET MVC application that uses Fluent NHibernate and AutoMapper. I am
I have an Asp.Net MVC application that works in the vs.net development web server.

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.