代码改变世界

疑难杂症:服务器标记“asp:ScriptManager”不明确。

2012-04-10 10:26  薛凯凯圆滚滚  阅读(844)  评论(1编辑  收藏  举报

首先说下原先的情况,就是原本老项目的Web解决方案是使用.net framework 2.0的老版本,

所以机器也安装过Microsoft ASP.NET 2.0 AJAX Extensions..AJAX插件..

但是因为后面种种原因反正就是要升级到.net framework 3.5的版本。

因此导致出现 (基类包括字段“ScriptManager1”,但其类型(System.Web.UI.ScriptManager)与控件(System.Web.UI.ScriptManager)的类型不兼容。)

这个问题是 ajax 版本和你的平台版本不符合 解决这个问题的办法是 只要修改原来注册的asp标记版本号换3.5的版本如下:

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" Namespace="System.Web.UI" TagPrefix="asp" %>

更换后

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35" Namespace="System.Web.UI" TagPrefix="asp" %>

 运行后可能还未能解决。我当时报出另一个错误 (服务器标记“asp:ScriptManager”不明确。请修改导致此多义性的关联注册并选取新的标记前缀。)

这时 我的解决版本是打开你的web.config文件 将以下所有xml代码的版本号更改为Version=3.5.0.0

<sectionGroup name="system.web.extensions"
  type="System.Web.Configuration.SystemWebExtensionsSectionGroup,
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
  PublicKeyToken=31bf3856ad364e35">
    <sectionGroup name="scripting"
    type="System.Web.Configuration.ScriptingSectionGroup,
    System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
    PublicKeyToken=31bf3856ad364e35">
      <section name="scriptResourceHandler"
      type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
      System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35" requirePermission="false" 
      allowDefinition="MachineToApplication"/>
      <sectionGroup name="webServices"
      type="System.Web.Configuration.ScriptingWebServicesSectionGroup,
      System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
      PublicKeyToken=31bf3856ad364e35">
        <section name="jsonSerialization"
        type="System.Web.Configuration.ScriptingJsonSerializationSection,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35" requirePermission="false" 
        allowDefinition="Everywhere" />
        <section name="profileService"
        type="System.Web.Configuration.ScriptingProfileServiceSection,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35" requirePermission="false" 
        allowDefinition="MachineToApplication" />
        <section name="authenticationService"
        type="System.Web.Configuration.ScriptingAuthenticationServiceSection,
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
        PublicKeyToken=31bf3856ad364e35" requirePermission="false" 
        allowDefinition="MachineToApplication" />
    </sectionGroup>
  </sectionGroup>
</sectionGroup>

找到<system.web>下的<pages>节点,添加下列控件的声明

<controls>
  <add tagPrefix="asp" namespace="System.Web.UI" 
    assembly="System.Web.Extensions, Version=1.0.61025.0, 
    Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>

在 <assemblies> 节点内添加对程序集的声明

<add assembly="System.Web.Extensions, Version=1.0.61025.0, 
  Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

找到 <httpHandlers> 节点,往里面添加以下谓词处理程序

<add verb="*" path="*.asmx" validate="false" 
  type="System.Web.Script.Services.ScriptHandlerFactory, 
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" 
  type="System.Web.Script.Services.ScriptHandlerFactory, 
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" 
  type="System.Web.Handlers.ScriptResourceHandler, 
  System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35" validate="false"/>

在<httpModules>节点内添加以下脚本模块处理程序

<add name="ScriptModule" 
  type="System.Web.Handlers.ScriptModule, System.Web.Extensions, 
  Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35"/>

在<SharePoint> 元素中的 <SafeControls> 节点内声明为安全控件

<SafeControl Assembly="System.Web.Extensions, 
  Version=1.0.61025.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" 
  TypeName="*" Safe="True" />

找到<configuration> 节点,添加以下Web 服务处理程序

<system.web.extensions>
    <scripting>
      <webServices>
      <!-- Uncomment this line to enable the authentication 
      service. Include requireSSL="true" if appropriate. -->
      <!--
        <authenticationService enabled="true" 
        requireSSL = "true|false"/>
      -->
      <!-- Uncomment these lines to enable the profile service. 
      To allow profile properties to be retrieved and modified in 
      ASP.NET AJAX applications, you need to add each property 
      name to the readAccessProperties and writeAccessProperties 
      attributes. -->
      <!--
        <profileService enabled="true" 
        readAccessProperties="propertyname1,propertyname2" 
        writeAccessProperties="propertyname1,propertyname2" />
      -->
      </webServices>
      <!--
      <scriptResourceHandler enableCompression="true" 
      enableCaching="true" />
      -->
    </scripting>
</system.web.extensions>
<system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules>
      <add name="ScriptModule" preCondition="integratedMode" 
      type="System.Web.Handlers.ScriptModule, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </modules>
    <handlers>
      <remove name="WebServiceHandlerFactory-Integrated" />
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" 
      preCondition="integratedMode" 
      type="System.Web.Script.Services.ScriptHandlerFactory, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" 
      path="*_AppService.axd" preCondition="integratedMode" 
      type="System.Web.Script.Services.ScriptHandlerFactory, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add name="ScriptResource" preCondition="integratedMode" 
      verb="GET,HEAD" path="ScriptResource.axd" 
      type="System.Web.Handlers.ScriptResourceHandler, 
      System.Web.Extensions, Version=1.0.61025.0, 
      Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </handlers>
</system.webServer>

按Ctrl + F 输出关键字全部替换就好了..

反正我是这样做的..OK 页面显示出来..

目前还没发现其他问题..