为什么部分视图在新窗口中打开并带有后期操作?

时间:2013-11-08 10:55:58

标签: asp.net-mvc asp.net-mvc-4 http-post asp.net-mvc-partialview

我有两种行动方法。 Get方法返回partialView与某些表单用户必须填写。

当我按下此表单上的按钮时,调用Post方法,这也会返回部分视图。但是post方法总是在新窗口中打开partialview。

但是我需要post方法来加载像PARTIAL这样的局部视图,而不是在新窗口中

你有什么想法吗?

[HttpGet]
public PartialViewResult EditProfile(int freelancerId)

    FreelancerProfile freelancerProfile = new FreelancerProfile();

    return PartialView(freelancerProfile); // EditProfile is opening in the part of window. it's ok.
}

[HttpPost]
public PartialViewResult EditProfile(FreelancerProfile freelancerProfile)
{
    repository.SaveProfileChangesFreelancer(freelancerProfile);

    return PartialView("EditProfile", freelancerProfile); //EditProfile is opening in the new window. it's trouble
}

1 个答案:

答案 0 :(得分:0)

  

但是post方法总是在新窗口中打开partialview。

这不是你的控制器可以做的事情,它必须在HTML中调用你的局部视图。