-1

So my question is similar to this SO post but I can not simply overwrite the document.

I'm using MVC and am able to call a controller's entry point from a View other than it's own.

the View (Say, ViewA) has a dialog, defined as:

$("#dialog-confirm").dialog({
            autoOpen: false,
            resizable: false,
            height: 390,
            width: 402,
            modal: true,
            buttons: {
                "Confirm": function () {

                    $.ajax({
                        type: "GET",
                        url: '/Result/Result', 
                        data: $(this).serialize(),
                        success: function(data)
                        {
                            window.location.href = "<%:Url.Action("~/Result/Result")%>";
                        }
                    });

                    $(this).dialog("close");
                },
                cancel: function(){ $(this).close();}}
           });

When I confirm the dialog, I hit the entry point I wanted to in the ResultsController, but then my browser navigates to localhost:8000/ViewA/~/Result/Result instead of localhost:8000/Result/Result

ResultController.cs

public ActionResult Result()
{            
     return RedirectToAction("Index");
}

How can I redirect to the page returned by Result() in the different controller?

Community
  • 1
  • 1
fifamaniac04
  • 2,343
  • 12
  • 49
  • 72

1 Answers1

3

Change

Url.Action("~/Result/Result")

To

Url.Action("Result", "Result")

https://msdn.microsoft.com/en-us/library/dd492758(v=vs.118).aspx

beautifulcoder
  • 10,832
  • 3
  • 19
  • 29