这是我的第一篇文章,因此你好:)
我想有条件地打开和关闭div.我究竟做错了什么?
@foreach (var m in Model.Recipes)
{
if (left)
{
<div class="rec-line">
}
if (left)
{
</div>
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个动作列表
//[HttpGet] (will come back to that!)
public ViewResult List(int page = 1)
{
//blah blah blah
return View(viewModel);
}
Run Code Online (Sandbox Code Playgroud)
在它的视图中我们渲染动作:
@{
Html.RenderAction("UpdateSearch");
}
Run Code Online (Sandbox Code Playgroud)
行动定义:
[ChildActionOnly]
[HttpGet]
public PartialViewResult UpdateSearch()
{
// do something and display a form in view
return PartialView(so);
}
[HttpPost]
public RedirectToRouteResult UpdateSearch(Options searchOptions)
{
// do something and redirect to List
return RedirectToAction("List");
}
Run Code Online (Sandbox Code Playgroud)
而且我得到:每当有人提交表单时,不允许子操作执行重定向操作异常.我是MVC3的新手,但看起来重定向也是一个POST,因为如果[HttpGet]上面的List方法被取消注释"无法找到资源".
如何在重定向时更改Http方法或者我做错了什么?我确实试过Bing,但没有成功.