9

我使用 Visual Studio 2012 for Web Express 在 ASP.Net 4.5 中开发了一个 Web 表单。它托管在 somee.com 上。当页面加载时,我收到以下错误:

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service        this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Unknown server tag 'webopt:BundleReference'.

Source Error: 


Line 9: <%: Scripts.Render("~/bundles/modernizr") %>
Line 10: </asp:PlaceHolder> 
Line 11: <webopt:BundleReference runat="server" Path="~/Content/css" /> 
Line 12: <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
Line 13: <meta name="viewport" content="width=device-width" />

Source File: /Site.Master Line: 11 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET  Version:4.0.30319.17929
4

5 回答 5

9

您需要确保您拥有对与“webopt”文件相关的特定程序集的引用。通常,您可以通过将其包含在 web.config 文件的部分中来执行此操作:

<pages>
    <controls>
        <add tagPrefix="webopt" assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms"  />
    </controls>
</pages>
于 2013-06-16T11:38:08.257 回答
9

实际上比这更简单。只需在 Nuget 上运行:Install-Package Microsoft.AspNet.Web.Optimization.WebForms

于 2014-06-29T18:08:15.743 回答
1
<?xml version="1.0" encoding="utf-8"?>
<!--You can set debug attribute to ="false"-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
  <namespaces>
    <add namespace="System.Web.Optimization" />
  </namespaces>
  <controls>
    <add assembly="Microsoft.AspNet.Web.Optimization.WebForms"       namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
  </controls>
 </pages>
 </system.web>

http://blogs.msdn.com/b/webdev/archive/2013/12/19/building-a-basic-web-forms-application-using-visual-studio-2013.aspx


请阅读:http: //blogs.msdn.com/b/prashant_upadhyay/archive/2011/07/15/pros-and-cons-of-using-debug-true-in-asp-net-applications-in-production -environment.aspx?重定向=真


于 2014-05-10T12:28:54.603 回答
1

false只需将 debug 属性设置为in即可打开捆绑和缩小web.config

于 2014-05-10T02:53:06.807 回答
0

右键单击您的 Web.config 并检查“构建操作”属性。如果设置为“无”,您将看到“未知服务器标签 'webopt:bundlereference”错误。将其更改为“内容”,一切都会好起来的。

于 2021-01-27T15:16:04.937 回答