我正在尝试通过添加用户控件来更新现有的 ASP/MVC 网站。我最终想将此用户控件添加到几个母版页,因为它是该站点的“接受 cookie 横幅”。
附带说明,我所做的其中一项更改是更新 Sites .csproj 文件以将 MvcBuildViews 的值设置为 true:
`<MvcBuildViews>true</MvcBuildViews>`
在我添加按钮之前,网站最初加载正常,我在底部看到我的横幅显示我的 cookie 消息:
然后作为我的下一步,我添加一个按钮,如下所示,让网站访问者接受使用cookie
`
<link rel="stylesheet" type="text/css" href="../../Content/NBS/css/cookienotice.css" />
<asp:MultiView ID="CookieSet" runat="server" ActiveViewIndex="0">
<asp:View ID="CookieView" runat="server">
<asp:Label ID="CookieNoticeLabel" runat="server" CssClass="cookieNotice">By clicking "Accept", you agree to our use of cookies. We use cookies to provide you with a great experience and to help our website run effectively.</asp:Label>
<asp:Button ID="Button2" runat="server" Text="Button" />
</asp:View>
</asp:MultiView>
`
下面是添加按钮后设计器中用户控件的视图:
此时,网站不再加载,我开始在输出窗口中收到这些错误:
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
Exception thrown: 'System.Web.HttpException' in System.Web.dll
有人能告诉我为什么添加这个按钮会给我带来问题吗?有没有办法更彻底地调试它,这样我就可以看看我是否缺少参考?
正如我上面提到的,我尝试将 MvcBuildViews 设置为 true:
`<MvcBuildViews>true</MvcBuildViews>`
我在浏览器中看到消息:
Failed to load resource: the server responded with a status of 404 () :44361/favicon.ico
我正在网上寻找这个错误和错误:
抛出异常:System.Web.dll 中的“System.Web.HttpException”
试图了解我的网站解决方案中没有加载或遗漏的内容。