在 View 中添加自定义控件会引发以下错误:-
"\\Views\\Error\\Index.cshtml(9): error CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments"
这是索引页面的代码: -
@{
ViewBag.Title = "Error";
}
<h2>
Sorry, an error occurred while processing your request.
</h2>
<div>@Html.RenderPartial("MyUserControl")
这是 MyUserControl 的代码: -
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
hi
从视图中删除@Html.RenderPartial("MyUserControl")
可以完美呈现页面。