C# 如何从ASP.NET MVC 4中的新操作返回现有视图?

C# 如何从ASP.NET MVC 4中的新操作返回现有视图?,c#,asp.net,.net,asp.net-mvc-4,C#,Asp.net,.net,Asp.net Mvc 4,努布需要帮助!)如何从同一控制器中的新操作返回现有视图? 例如,我有以下代码: [HttpGet] public ActionResult Index() { return View(); //returns Index.cshtml } [HttpPost] public ActionResult Index(string id, string condition) { SomeModel.ID = id; SomeModel.Condition = condi

努布需要帮助!)如何从同一控制器中的新操作返回现有视图? 例如,我有以下代码:

[HttpGet]
public ActionResult Index()
{
     return View(); //returns Index.cshtml
}

[HttpPost]
public ActionResult Index(string id, string condition)
{
     SomeModel.ID = id;
     SomeModel.Condition = condition;
     return View(SomeModel); //returns Index.cshtml delegating the model
}

public ActionResult someAction()
{
     return View(); //How to make this action return Index.cshtml??
}

您可以指定要返回的视图名称:

public ActionResult someAction()
{
     return View("Index"); 
}
加上

返回视图(“YourView”)

如果你想发送一个模型,你可以这样做

var模型=新的YourViewModel {

}


返回视图(“YourView”,模型)

返回视图(“索引”)我试图这样做,但我面临一个error@user3493623什么类型的错误?潜在的危险请求。路径值已从客户端@user3493623接收到。那么,恐怕您的问题是其他问题。可能还有更多的代码没有显示给我们,这与错误有关。
public ActionResult someAction()
{
     return View("Index"); 
}