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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:45:33+00:00 2026-05-24T10:45:33+00:00

It starts here in the .ascx on a button click. <script type=text/javascript> function acceptG(id)

  • 0

It starts here in the .ascx on a button click.

<script type="text/javascript">

function acceptG(id) {
    jQuery.get('<%: Url.Action("Accept", "Gift") %>', { id: id });
}

</script>

Then, here is the Controller is where the RedirectToAction is:

 [Authorize]
    public ActionResult Accept(long id)
    {
        var result = _gtService.AcceptG(id, User.UserID);
        if (result.Success)
            return RedirectToAction("Index", "Magnets");
        else 
        return View("InvalidG");             
    }

Here is the Index

 public ActionResult Index()
    {
        ViewData["Count"] = _souvenirService.GetDataForUser(User.UserID).Count();
        return View();
    }

One thing to remember is when using the Menu and hitting this Index the page comes up successfully, so it does work. But when using the RedirectToAction it hits all the code but does not redirect. Any help is appreciated.

  • 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-24T10:45:34+00:00Added an answer on May 24, 2026 at 10:45 am

    Jquery is not magic, its just a wrapper for javascript. When you do a redirect on server that doesn’t mean that your browser(ajax-request) will automatically understand what you mean to do. You have to tell browser that we want to redirect. I have created very tiny system for your need , but you can create complex one-as per your applications requirement.

    <script type="text/javascript">
    
    function acceptG(id) {
        jQuery.ajax({
              url:'<%: Url.Action("Accept", "Gift") %>',
              data:{ id: id },
              success:function(data)
              {
                   if(data=='Redirect') 
                   {
                        window.location='<%: Url.Action("Index", "Magnets") %>';
                   }
                   else
                   {
                       //do something else
                   }
              }
         });
    }
    
    </script>
    
    
    
     [Authorize]
        public ActionResult Accept(long id)
        {
            var result = _gtService.AcceptG(id, User.UserID);
            if (result.Success)
                if(Request.IsAjaxRequest())
                {
                      return Content('Redirect')
                }
                return RedirectToAction("Index", "Magnets");
            else 
            return View("InvalidG");             
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have some original text: here is some text that has a
I'm trying to create a SQL Function that tests whether a parameter starts with
So here I am just about to start a big project using LINQ to
I've hit a blank here and would appreciate a kick start. I have two
Here is my code: ThreadStart threadStart = controller.OpenFile; Thread thread = new Thread(threadStart); thread.Start();
I'm trying to install a service using InstallUtil.exe but invoked through Process.Start . Here's
Once a user starts a session (or logs in, for a registered user, to
My ASP.NET always starts like this with the internal server: http://localhost:50793/Website/ I use FckEditor
When a java based application starts to misbehave on a windows machine, you want
If our server (running on a device) starts before a DHCP lease had been

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.