2016-03-29 16 views
0

我有我的模式形式的這個錯誤問題:Child actions are not allowed to perform redirect actions.兒童的行爲是不允許執行我的情態形式重定向行爲

這是我的控制器:

 public ActionResult Create() 
    { 
     return PartialView(); 
    } 
    [HttpPost] 
    [ValidateAntiForgeryToken] 
    public ActionResult Create([Bind(Include = "Id,Title")] TypePart typePart) 
    { 
     try 
     { 
      if (ModelState.IsValid) 
      { 
       db.TypeParts.Add(typePart); 
       db.SaveChanges(); 
       return RedirectToAction("Index"); 
      } 
     } 
     catch 
     { 


     } 
     return PartialView(typePart); 
    }` 

這是我的看法:

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> 
    Add</button> 
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria- labelledby="myModalLabel"> 
<div class="modal-dialog" role="document"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
      <h4 class="modal-title" id="myModalLabel">Add</h4> 
     </div> 
     <div class="modal-body" id="bodymodal"> 
      @Html.Action("Create","TypeParts") 

     </div> 

    </div> 
</div> 

+0

幫助呢? http://stackoverflow.com/questions/25015833/child-actions-are-not-allowed-to-perform-redirect-actions-after-setting-the-sit –

+0

不!我看到這個鏈接,但沒有工作 –

回答

0

你有沒有嘗試過;
@Url.Action("Create","TypeParts")
而不是
@Html.Action("Create","TypeParts")

根據解決方案here,可以解決這個問題

相關問題