PageMethods呼叫负载整个页面的

PageMethods呼叫负载整个页面的

本文介绍了ASP.NET AJAX PageMethods呼叫负载整个页面的.NET 4.5 IIS 7.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打电话PageMethod的在aspx页面的codebehind。我得到了整个页面,而不是WEBMETHOD响应的响应。此外,我打过电话使用jQuery相同的WebMethod,并得到了整个页面的响应。

I am calling pageMethod in codebehind of aspx page. I get the response for whole page instead of webMethod response. Also, I tried calling the same webMethod using jquery and got the whole page as response.

Client:

  <asp:ScriptManager ID="scriptManager1" runat="server" EnablePartialRendering="True"
 EnablePageMethods="true" EnableScriptGlobalization="true" EnableScriptLocalization="true" >

function TestNumber() {
PageMethods.getNumber(ResponseTest);
}

 function ResponseTest(response){
          var num = response.d;
      }

CodeBehind:

 [WebMethod]
 public static int getNumber()
        {
            return accountNumber;
        }

我使用.NET 4.5.1和IIS7.5,我认为这个问题是realted到在VS2013内置扩展名的URL。我使用下面的web.config sys.webserver

I am using .NET 4.5.1 and IIS7.5 and I think the issue is realted to in built extensionless URLS in VS2013. I am using the following web.config sys.webserver

  <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
 <modules runAllManagedModulesForAllRequests="true">
      <remove name="ScriptModule" />
      <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </modules>
        <handlers>
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
          <remove name="OPTIONSVerbHandler" />
          <remove name="TRACEVerbHandler" />
          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
      </system.webServer>

我想同样的通过Jquery的Ajax调用,并得到整个页面。我失去了什么东西?

I tried the same through Jquery ajax call and got whole page. Am i missing any thing?

推荐答案

如果您使用的是友好的URL,然后添加

If you are using friendly urls, then add

PageMethods.set_path(PageMethods.get_path() + '.aspx');

你的JS

祝你好运!

这篇关于ASP.NET AJAX PageMethods呼叫负载整个页面的.NET 4.5 IIS 7.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:55