C# 返回到命名视图不';我不能在萨姆比特之后工作
在发布到服务器端方法后,我希望将用户返回到其来源的视图,即:C# 返回到命名视图不';我不能在萨姆比特之后工作,c#,.net,asp.net-mvc,C#,.net,Asp.net Mvc,在发布到服务器端方法后,我希望将用户返回到其来源的视图,即: .../BrokerDashboard/Profile/Index 方法如下: [HttpPost] public ActionResult Profile(ProfileModel Model) { // do stuff return View("Index", Model); } 这里有一个逻辑需要在表单发布后执行: public ActionResult Index(string contactid) {
.../BrokerDashboard/Profile/Index
方法如下:
[HttpPost]
public ActionResult Profile(ProfileModel Model)
{
// do stuff
return View("Index", Model);
}
这里有一个逻辑需要在表单发布后执行:
public ActionResult Index(string contactid)
{
// do stuff
}
但在发布后,浏览器会在此处结束:
.../BrokerDashboard/Profile/Profile
这意味着
public ActionResult Index()
在发布后不会再次被调用。我想你要找的是redirectoaction()
它会导致重定向并触发你的Index controller方法
好 啊。我在追踪。但是我需要更改退货类型吗?现在我得到了“并非所有代码路径都返回一个值”。您应该返回该方法的结果(我将更新答案)是的-在我做了注释之后意识到:-)。谢谢!测试
[HttpPost]
public ActionResult Profile(ProfileModel Model)
{
// do stuff
return RedirectToAction("Index", Model);
}