P.Brian.Mackey
P.Brian.Mackey

Reputation: 44285

MVC routes me to non-existent path

I am using the default route. I have setup a method:

[HttpPost]
public ActionResult HtmlButton2(FormCollection collection)
{
    //implementation
    return View("Index");
}

Which when it runs it returns me to

http://serverName/{controller}/HtmlButton2

The POST originates from http://serverName/ (visible in the URL..the actual page is http://serverName/Index).

Ideally, I would like to be routed back to

http://serverName

I believe the problem is in my

return View("Index"); 

The Index page is visible, but the problem is that when I refresh the page, the aforementioned HtmlButton2() method keeps handling the calls...which I do not want.

How can I fix it?

Upvotes: 1

Views: 96

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 190952

You are looking for return RedirectToAction("Index"); When you are returning View("Index") you are telling MVC to render the view, not change the URL.

Upvotes: 2

Related Questions