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 8239383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:07:41+00:00 2026-06-07T20:07:41+00:00

I have added some web methods to my ASP.NET page like the following to

  • 0

I have added some web methods to my ASP.NET page like the following to enable AJAX calls using jQuery on the client side of my application:

public partial class MyPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // Page load logic...
    }

    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public static string MyWebMethod()
    {
        // web method logic...
    }
}

However, I noticed using the debugger that my web methods are being processed on a different AppDomain than my ASP.NET Page’s AppDomain, hence each one of them has its own set of static variables which is causing me some trouble.

So I would like to know if it’s somehow possible to host WebMethods (or a web-service) and an ASP.NET app on the same AppDomain, enabling both of them access to the same set of static variables?

Thanks in advance!

EDIT 1

I’m hosting my app on IIS 7.0

EDIT 2

As Jupaol’s answer clearly shows it is possible to host WebMethods and an ASP.NET page on the same appDomain, nevertheless here is what I found after running more tests:

If my jQuery.ajax call sets its URL like this:

$.ajax({
         url: "/MyFolder/MyPage.aspx/MyWebMethod",
         contentType: "application/json; charset=utf-8",
         success: AjaxSuccess,
         error: AjaxError
});

IIS creates two appDomains on my Web site (same web site key), one for the page request and another for the WebMethod request. Their FriendlyNames are showed below:

  • “/LM/W3SVC/1/ROOT-6-129872125368848248” (WebMethod)
  • “/LM/W3SVC/1/ROOT/WebApp-5-129872125273487796” (ASP.NET page request)

However, if the jQuery.ajax call URL is set like this:

$.ajax({
         url: "MyPage.aspx/MyWebMethod",
         contentType: "application/json; charset=utf-8",
         success: AjaxSuccess,
         error: AjaxError
});

Only one appDomain gets created to serve both requests:

  • “/LM/W3SVC/1/ROOT/WebApp-7-129872126989518526”

Unfortunately I wasn’t able to find an explanation for this behaviour, and the only thing I can think of that may be related to this issue is that my web site uses https on some pages and not in others.

  • 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-06-07T20:07:44+00:00Added an answer on June 7, 2026 at 8:07 pm

    Are you sure that you are comparing the AppDomain’s ID???

    I just made an experiment and they do belong to the same AppDomain

    That could not always be true if you are explicitly creating AppDomains in code.

    Example: (I just updated an old example I had, focus on the AppDomain.CurrentDomain.Id)

    Code Behind

        protected void Page_Load(object sender, EventArgs e)
        {
            this.lblMessage.Text += "AppDomain ID: " + AppDomain.CurrentDomain.Id.ToString() + "<br/>";
        }
    
        [WebMethod]
        public static string Execute1()
        {
            JavaScriptSerializer j = new JavaScriptSerializer();
            string r = string.Empty;
            var o = Observable.Start(() =>
            {
                Thread.Sleep(2000);
                r = "My Name1: " + DateTime.Now.ToString() + " Background thread: " + Thread.CurrentThread.ManagedThreadId.ToString();
            }, Scheduler.NewThread);
            o.First();
            r += " Main thread: " + Thread.CurrentThread.ManagedThreadId.ToString();
            r += " AppDomain ID: " + AppDomain.CurrentDomain.Id.ToString();
            r = j.Serialize(new { res = r });
            return r;
        }
    

    Output

    enter image description here

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

Sidebar

Related Questions

I have added some animation using jquery but it's not working: $('.test-container').click(function(){ $(this).css('background-color', 'rgb(119,
We have been using log4net for logging our asp.net web forms application. Our logging
I have some ASP.NET web services which all share a common helper class they
The context I have an Asp .Net web application with some pages that inherit
I have just added routing in a new asp.net 4 web forms application, and
I have added some settings to my c# application using the configuration editor. There
I have a custom ASP.NET user control that is added to a panel on
I have the following WebGrid in my ASP.NET MVC3 test application. It displays a
I have created a WCF web service, i am calling it from ASP.NET 1.1
I have an ASP.NET web site where i am having App_code folder in which

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.