开发者

MVC routes me to non-existent path

I am using the default ro开发者_如何学Goute. 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜