Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> 電腦軟件教程 >> 服務器技術 >> 關於服務器 >> 服務器標記“asp:ScriptManager”不明確解決參考

服務器標記“asp:ScriptManager”不明確解決參考

日期:2017/2/8 10:10:47      編輯:關於服務器

首先說下原先的情況,就是原本老項目的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>

Copyright © Windows教程網 All Rights Reserved