Visual Studio 2008 IIS上配置的框架:2.0
我有在asmx文件中调用Web服务的代码。 我已经安装了一个脚本管理器来添加Web服务。
// This function calls the Web Service method.
function GetScrapTimeCalculation() {
var Minutes = $("#" + '<%= NumericBoxQuantityMin.ClientID %>').val();
Samples.AspNet.ScrapTimeCalculation.GetScrapTimeCalculation(document.getElementById(some parameters, OnSucceeded);
}
<asp:ScriptManager runat="server" ID="scriptManager" EnablePageMethods="true">
<Services>
<asp:ServiceReference Path="~/Webservice/ScrapTimeCalculation.asmx" />
</Services>
</asp:ScriptManager>
这是我的网络服务代码:
<%@ WebService Language="C#" Class="Samples.AspNet.ScrapTimeCalculation" %>
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Xml;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Web.Script.Serialization;
namespace Samples.AspNet
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class ScrapTimeCalculation : System.Web.Services.WebService
{
[WebMethod]
public string GetScrapTimeCalculation(some parameters)
{
try
{
Int32 fabID = Convert.ToInt32(Server.HtmlEncode(Fab_ID));
string date = Server.HtmlEncode(ScrapDate);
Int32 min = Convert.ToInt32(Server.HtmlEncode(minutes));
Fab_dechet mObj = null;
if (!String.IsNullOrEmpty(date) || !String.IsNullOrEmpty(Server.HtmlEncode(minutes)) || !String.IsNullOrEmpty(Server.HtmlEncode(Fab_ID)))
{
mObj = new Fab_dechet();
return (mObj.GetScrapTimeCalculation(fabID, 0, date, min)).ToString();
}
else
{
return "0";
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
但是当我运行此代码时,我得到以下javascript错误 “asp net ajax客户端框架无法加载”
当我使用4.0框架时,我正确运行!
请帮忙! TIA!
Webconfig的处理程序标记
<httpHandlers>
<remove path="*.asmx" verb="*" />
<add verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory" validate="false"/>
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
<add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>