说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:行 24: </div>--%>行 25:行 26: <% Html.RenderPartial("Header.ascx"); %>行 27:行 28: </div>源文件: e:\gz_project\VS2008\Design\Design.Web\U\UserDomains\Home.aspx 行: 26堆栈跟踪:[NullReferenceException: 未将对象引用设置到对象的实例。]System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName) +10ASP.u_userdomains_home_aspx.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in e:\gz_project\VS2008\Design\Design.Web\U\UserDomains\Home.aspx:26System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19System.Web.UI.Page.Render(HtmlTextWriter writer) +29System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +59System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
1 回答
慕容3067478
TA贡献1773条经验 获得超3个赞
如果你的partial(本例中也就是Header.ascx)是在当前请求的controller下(也就是位于目录/Views/nameController下)或共享目录下(也就是/Views/Shared下),那么你只要把后缀.ascx去掉就行了,也就是把你的第26行换成<% Html.RenderPartial("Header.ascx"); %>。
如果你的partial位于其它位置,那么你需要引用全虚拟目录,目录依你项目而定,形式如下:
<%: Html.Partial("~/Views/Shared/Partials/MyOtherPartial.ascx") %>
注意,这个时候需要.ascx后缀。
添加回答
举报
0/150
提交
取消