2016-03-29 5 views
0

Ich habe mit diesem Fehler ein Problem in meinem modalen Formular umleiten Aktionen in meiner Modal Form ausführen dürfen: Child actions are not allowed to perform redirect actions.Kinder Aktionen sind nicht

Dies ist mein Controller:

 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); 
    }` 

Und das ist meine Ansicht nach :

<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

Diese Hilfe lösen? http://stackoverflow.com/questions/25015833/child-actions-are-not-allowed-to-perform-redirect-actions-after-setting-the-sit –

+0

nein! Ich habe diesen Link gesehen aber nicht funktioniert –

Antwort

0

Haben Sie versucht;
@Url.Action("Create","TypeParts")
statt
@Html.Action("Create","TypeParts")

Nach Lösung here, kann es dieses Problem