Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6241723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:49:11+00:00 2026-05-24T11:49:11+00:00

As PageMethods in ASP.NET need to be static methods and marked as web method,

  • 0

As PageMethods in ASP.NET need to be static methods and marked as web method, I was in a impression that instance of that particular page won’t be created when a page method is called.

But when I tried putting a break point in the constructor it was getting hit every time a pagemethod is called. Can somebody let me know what is need for constructing an instance?

Thanks

Server side

public partial class PageMethod : System.Web.UI.Page
{

    public PageMethod()
    {

    }

    [System.Web.Services.WebMethod()]
    public static string GetMessage()
    {
        return "Page Method Call";
    }
}

Client Side (used JQuery)

$.ajax({ type: 'POST',
                url: /PageMethod.aspx/GetMessage,
                data: null,
                success: onSuccess,
                contentType: "application/json; charset=utf-8",
                dataType: 'JSON',
                error: onError      
            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:49:12+00:00Added an answer on May 24, 2026 at 11:49 am

    EDIT

    Indeed constructor is called!! See callstack of pagemethod’s call:

    PageMethodTest_WebApplication3.DLL!PageMethodTest_WebApplication3._Default._Default() Line 9    C#
      App_Web_iielssqo.dll!ASP.default_aspx.default_aspx() + 0x43 bytes C#
      App_Web_iielssqo.dll!__ASP.FastObjectFactory_app_web_iielssqo.Create_ASP_default_aspx() + 0x43 bytes  C#
      System.Web.dll!System.Web.Compilation.BuildResultCompiledType.CreateInstance() + 0x21 bytes   
      System.Web.dll!System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(System.Web.VirtualPath virtualPath, System.Type requiredBaseType, System.Web.HttpContext context, bool allowCrossApp, bool noAssert) + 0x78 bytes    
      System.Web.dll!System.Web.UI.PageHandlerFactory.GetHandlerHelper(System.Web.HttpContext context, string requestType, System.Web.VirtualPath virtualPath = {/Default.aspx}, string physicalPath) + 0x22 bytes  
      System.Web.dll!System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(System.Web.HttpContext context, string requestType, System.Web.VirtualPath virtualPath, string physicalPath) + 0x29 bytes  
      System.Web.dll!System.Web.HttpApplication.MapHttpHandler(System.Web.HttpContext context, string requestType, System.Web.VirtualPath path, string pathTranslated = "C:\\Documents and Settings\\Administrator\\My Documents\\Visual Studio 2008\\Projects\\PageMethodTest_WebApplication3\\PageMethodTest_WebApplication3\\Default.aspx", bool useAppConfig) + 0xa1 bytes  
    

    ASP.NET engine routes request from pagemethod to aspx-handler-factory (PageHandlerFactory). As far as I understand it’s inner logic of ASP.NET. Therefore it’s correct 🙂

    Now check asmx-webmethod call:

      PageMethodTest_WebApplication3.DLL!PageMethodTest_WebApplication3.WebService1.HelloWorld() Line 22    C#
      [Native to Managed Transition]    
      [Managed to Native Transition]    
      System.Web.Extensions.dll!System.Web.Script.Services.WebServiceMethodData.CallMethod(object target, System.Collections.Generic.IDictionary<string,object> parameters) + 0x15c bytes   
      System.Web.Extensions.dll!System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(object target, System.Collections.Generic.IDictionary<string,object> parameters) + 0x1f bytes   
      System.Web.Extensions.dll!System.Web.Script.Services.RestHandler.InvokeMethod(System.Web.HttpContext context = {System.Web.HttpContext}, System.Web.Script.Services.WebServiceMethodData methodData = {System.Web.Script.Services.WebServiceMethodData}, System.Collections.Generic.IDictionary<string,object> rawParams) + 0x61 bytes    
      System.Web.Extensions.dll!System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(System.Web.HttpContext context = {System.Web.HttpContext}, System.Web.Script.Services.WebServiceMethodData methodData) + 0x55 bytes    
      System.Web.Extensions.dll!System.Web.Script.Services.RestHandler.ProcessRequest(System.Web.HttpContext context) + 0xc bytes   
      System.Web.Extensions.dll!System.Web.Script.Services.ScriptHandlerFactory.HandlerWrapper.ProcessRequest(System.Web.HttpContext context) + 0xe bytes   
      System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0xb6 bytes   
    

    Here using another httphandler-factory – ScriptHandlerFactory.

    PS Moorthy, thanks! Good question 🙂 ‘Live and learn!’


    static / [WebMethod] – cos page method is called solely by ajax (without page creation).

    If you wanna have Page instance you should use UpdatePanel or AJAX.NET Controls (for instance DevExpress, AjaxToolKit).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use System.Web.Services.WebMethodAttribute to make a public static method of an ASP.NET page callable
I am using ASP.Net Ajax's Page Methods and I have an issue that an
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add
I know that when declaring a page method in ASP.NET, I can specify a
I have some PageMethods (static methods in a page marked with <WebMethod> ) defined
I am trying to use page methods in my asp.net page. I have enable
I am using ASP.NET page methods with jQuery.... How do I get the value
I am using ASP.NET page methods with jQuery. Here is my code, $.ajax({ type:
I would like to utilize the ASP.NET AJAX Page Methods functionality with a user
We are using ASP.NET with a lot of AJAX Page Method calls. The WebServices

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.