【发布时间】:2016-07-13 10:07:10
【问题描述】:
我正在开发一个应用程序,我需要添加一个创建视图以在索引视图中输入数据(我在其中显示数据库表中的所有数据),以从同一视图输入数据. Create View 已经渲染没有任何问题,但是在回发时出现错误:error="child-actions-are-not-allowed-to-perform-redirect-actions"。
控制器:
// GET: /Brands/
public async Task<ActionResult> Index()
{
return View(await db.Brands.ToListAsync());
}
// GET: /Brands/Create
public ActionResult Create()
{
return PartialView("_Create", new BootstrapModalTest.Models.Brand());
}
// POST: /Brands/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create([Bind(Include="BrandId,BrandName,BrandCode")] Brand brand)
{
if (ModelState.IsValid)
{
db.Brands.Add(brand);
await db.SaveChangesAsync();
return PartialView("_Create", brand);
}
return PartialView("_Create", brand);
}
这里是Index.cshtml:
div class="panel panel-primary">
<div class="panel-heading" style=" padding:2px 7px 0px 6px;"><h4>Frames</h4></div>
<div class="panel-body " style="padding:4px;">
@{Html.RenderAction("Create", "Brands");}
</div>
<table class="table table-bordered>
// some data
【问题讨论】:
-
你有什么问题?
-
m 收到错误“child-actions-are-not-allowed-to-perform-redirect-actions”
-
在问题中解释(不是在 cmets 中!)
-
回发时出现此错误
标签: c# asp.net-mvc asp.net-mvc-3 asp.net-mvc-4