问题描述
我将表单网站转换为应用程序,到目前为止一切正常.我不断收到绿色波浪线和元素X"不是已知元素的错误.这几乎适用于每个元素,Gridview、标签、更新面板、超链接字段、绑定字段等...
I converted a forms website into an application and everything has been working just fine until now. I keep getting the green squiggly lines and the error that Element 'X' is not a known element. This is on almost every element, Gridview, Label, Update Panel, Hyperlink Field, Bound Field, etc...
我的 web.config 包含
my web.config contains
<pages theme="basic">
<controls>
<add tagPrefix="ajax" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
所以 ajax 和 asp 是可行的前缀.非常奇怪的是,它只发生在少数用户控件上,所有其他用户控件都很好,并且错误永远不会出现.我已经尝试重新启动,一切似乎都没有解决.所有母版页、网页和大约 90% 的用户控件都很好,只是在少数用户控件上,超级烦人!
so ajax and asp are viable prefixes. The very odd thing is that it is only happening on a few user controls, all other user controls are fine and the errors never show up. I have tried rebooting and everything and nothing seems to fix it. All masterpages, web paages, and about 90% of the user controls are fine, its only on a few user controls and super annoying!
推荐答案
如果您的 web.config 文件中的 compilation
元素具有 targetFramework="4.0"
属性,我认为不再需要对 System.Web.Extensions 程序集的引用.如果您查看位于 %WINDIR%Microsoft.NETFrameworkv4.0.30319Config
的根级 web.config 文件,您会注意到以下行已经在 web.config 文件的 <controls>
部分:
If the compilation
element in your web.config file has the targetFramework="4.0"
attribute, I don't think the references to the System.Web.Extensions assembly are required anymore. If you look at the root-level web.config file at %WINDIR%Microsoft.NETFrameworkv4.0.30319Config
, you will notice that the following lines are already in the <controls>
section of the web.config file:
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls.Expressions" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<compilation><assemblies>
部分也引用了 System.Web.Extensions 程序集
The System.Web.Extensions assembly is also referenced in the <compilation><assemblies>
section
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
以及以下 <httpHandlers>
也添加了
<add verb="*" path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/>
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False" />
另外,默认注册以下<httpModules>
<add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
简而言之,您的 web.config 文件可能不应该包含对 System.Web.Extensions 程序集的任何引用,因为它已经在根级 web.config 文件中以几乎所有可能的方式被引用.
In short, your web.config file probably should not contain any references to the System.Web.Extensions assembly because it is already referenced in almost every conceivable way in the root-level web.config file.
其他参考:如何:将 ASP.NET Web 应用程序升级到 ASP.网络 4
这篇关于元素“X"不是已知元素 - Web 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!