【问题标题】:Unknown server tag 'webopt:BundleReference'未知的服务器标签“webopt:BundleReference”
【发布时间】:2021-01-27 23:16:04
【问题描述】:

我使用 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

【问题讨论】:

  • 从 NuGet 下载 Microsoft.AspNet.Web.Optimization.WebForms 包为我解决了这个问题:nuget.org/packages/Microsoft.AspNet.Web.Optimization.WebForms
  • 如果包需要更新的话,即使安装了仍然会出现这个错误,很容易在webforms上通过控制台安装标签搜索,值得一试。

标签: asp.net


【解决方案1】:

您需要确保引用了与“webopt”文件相关的特定程序集。通常,您可以通过将其包含在 web.config 文件的部分中来做到这一点:

<pages>
    <controls>
        <add tagPrefix="webopt" assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms"  />
    </controls>
</pages>

【讨论】:

  • 我发现了问题。我在网站上发布了一个调试版本。发布了发布版本并解决了问题。
  • 感谢您的回复,skhurams。
【解决方案2】:

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

【讨论】:

    【解决方案3】:
    <?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?Redirected=true


    【讨论】:

      【解决方案4】:

      只需将web.config 中的调试属性设置为false 即可打开捆绑和缩小。

      【讨论】:

      • 您应该添加一些解释,说明这将如何以及为什么会有所帮助。
      • 这为我删除了警告消息。谢谢! +1
      【解决方案5】:

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

      【讨论】:

        猜你喜欢
        • 2011-07-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多