问题描述
我转换表单的网站到一个应用程序,一切都已经工作得很好,直到如今。我不断收到绿色的波浪线和元素'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是可行的prefixes。很奇怪的是,它只是发生在少数用户控件,所有其他用户的控制都很好,并且错误永不露面。我试图重新启动和一切,似乎没有任何解决它。所有masterpages,网页paages,和用户控制的约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文件中的元素有 targetFramework = 4.0
属性,我不认为到组装都需要再在System.Web.Extensions程序的引用。如果你看一下根级的web.config文件的%WINDIR%\\ Microsoft.NET \\框架\\ v4.0.30319 \\ Config中
,你会发现下面的行已经在&LT;控制与GT;
web.config文件的部分:
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.NET\Framework\v4.0.30319\Config
, 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"/>
在System.Web.Extensions程序组件中还引用&LT;编译&GT;&LT;&集会GT;
部分
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
和以下&LT;&HttpHandlers的GT;
添加以及
<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" />
此外,以下&LT;&的HttpModules GT;
默认注册
<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.NET 4
这篇关于元素'X'不是一个已知的元素 - Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!