Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

call asp net pagemethod webmethod with jquery returns whole page

call asp net pagemethod webmethod with jquery returns whole page  using -',jquery,web-services,asmx,pagemethods'

jQuery 1.3.2, ASP.NET 2.0.  Making an AJAX call to a PageMethod (WebMethod) returns the full/whole page instead of just the response.  A breakpoint on the page method shows it's never getting hit.  I have the [WebMethod] attribute on my method, and it is public static, returns string and accepts no params.  I even tried adding [ScriptService] at the top of my class to see if it helped, but it did not.

I have seen this post which had my same symptoms, but I am still having a problem.  I read and I feel like I'm following this to the T, but still no luck.

The jQuery call I'm making is:

    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    data: '{}',
    dataType: 'json',
    url: 'MyPage.aspx/SomePageMethod',
    success: function(result){

The request/response headers, as per Firebug in FF3, are as follows

Response Headers
Server  ASP.NET Development Server/
Date    Tue, 24 Feb 2009 18:58:27 GMT
X-AspNet-Version    2.0.50727
Cache-Control   private
Content-Type    text/html; charset=utf-8
Content-Length  108558
Connection  Close

Request Headers
Host    localhost:2624
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2009011913 Firefox/3.0.6
Accept  application/json, text/javascript, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  300
Connection  keep-alive
Content-Type    application/json; charset=utf-8
X-Requested-With XMLHttpRequest
Referer http://localhost:2624/MyApp/MyPage.aspx
Content-Length  2
Cookie  ASP.NET_SessionId=g1idhx55b5awyi55fvorj055;

I've added a ScriptManager to my page just for kicks to see if it helped, but no luck there.

Any suggestions?

asked Oct 6, 2015 by manju bhargava
0 votes

Related Hot Questions

Government Jobs Opening