ASP.NET MVC的ActionResult查看()不改变网址 [英] ASP.NET MVC ActionResult View() not changing url

查看:114
本文介绍了ASP.NET MVC的ActionResult查看()不改变网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法...

[HttpPost]
public ActionResult Start(SomeViewModel someViewModel) { ... }

这是基于一些条件返回之类的东西回报视图(无效)视图(NOTFOUND)视图(运行,anotherViewModel)等的问题是,无论什么看法我present,URL不改变以反映新的控制器/行动。当我查看要张贴到不同的操作这就带来了一个问题。我该如何解决这个问题?

that based on some conditions returns things like return View("Invalid"), View("NotFound"), View("Run", anotherViewModel), etc. The problem is that no matter what view I present, the URL does not change to reflect the new controller/action. This poses a problem when my View wants to post to a different action. How can I fix this?

推荐答案

查看(...)方法的重定向,他们只是呈现出当前请求的特定视图。如果您需要在目标视图的形式特定的URL,就可以在控制器/动作细节的形式传递方式:

The View(...) methods don't redirect, they simply render out the specific view on the current request. If you need to target a specific url in the form of your view, you can pass in the controller/action details to the form method:

Html.BeginForm("action", "controller")

...等

这篇关于ASP.NET MVC的ActionResult查看()不改变网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆