我试图在点击时调用div中的局部视图.我写过:
@Ajax.ActionLink("Second","Second",new AjaxOptions() { HttpMethod = "GET",UpdateTargetId = "partials",InsertionMode = InsertionMode.Replace }) <div id="partials"> </div> <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/additional-methods.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/mvc/5.2/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
在我的Index.cshtml中.我的控制器看起来像这样:
public ActionResult Index() { return View(); } public PartialViewResult Second() { return PartialView("Second.cshtml"); }
但我的错误说我的部分视图无法找到:
~/Views/switchPartial/Second.cshtml.aspx ~/Views/switchPartial/Second.cshtml.ascx ~/Views/Shared/Second.cshtml.aspx ~/Views/Shared/Second.cshtml.ascx ~/Views/switchPartial/Second.cshtml.cshtml ~/Views/switchPartial/Second.cshtml.vbhtml ~/Views/Shared/Second.cshtml.cshtml ~/Views/Shared/Second.cshtml.vbhtml
但我在switchPartial文件夹中有它.
如果我在我的div中写@ Html.Partial(“Second”)它会正确呈现我的局部视图.
我做错了什么?