Share via


ApplicationDomain.VirtualPath Property

Definition

Gets the virtual path of the application domain

public:
 property System::String ^ VirtualPath { System::String ^ get(); };
public string VirtualPath { get; }
member this.VirtualPath : string
Public ReadOnly Property VirtualPath As String

Property Value

The virtual path of the application domain.

Examples

The following example demonstrates how to view all properties and unload an application domain.

using System;
using Microsoft.Web.Administration;

namespace AdministrationSnippets
{
    public class MicrosoftWebAdministrationApplicationDomain
    {
        ServerManager manager = new ServerManager();

        public void RecycleApplicationDomains()
        {
            Console.WriteLine("Displaying Worker Processes & Application Domains...");
            GetApplicationDomains();
            
            Console.WriteLine("Unloading all application domains");
            UnloadApplicationDomains();

            Console.WriteLine("Displaying Worker Processes & Application Domains with new IDs...");
            GetApplicationDomains();
        }
        public void UnloadApplicationDomains()
        {
            foreach (WorkerProcess proc in manager.WorkerProcesses)
            {
                foreach (ApplicationDomain ad in proc.ApplicationDomains)
                {
                    ad.Unload();
                }
            }
        }
        public void GetApplicationDomains()
        {
            foreach (WorkerProcess proc in manager.WorkerProcesses)
            {
                Console.WriteLine("Worker Process Found:");
                Console.WriteLine("\tProcessId:   {0}", proc.ProcessId);
                Console.WriteLine("\tProcessGuid: {0}", proc.ProcessGuid);
                Console.WriteLine("\tAppPoolName: {0}", proc.AppPoolName);
                Console.WriteLine("\tApplication Domains:");
                foreach (ApplicationDomain ad in proc.ApplicationDomains)
                {
                    Console.WriteLine("\t\tApplication Domain Found:");
                    Console.WriteLine("\t\t{0}", ad.Id );
                    Console.WriteLine("\t\t{0}", ad.VirtualPath );
                    Console.WriteLine("\t\t{0}", ad.PhysicalPath );
                    Console.WriteLine("\t\t{0}", ad.Idle);
                }
            }
        }
    }
}

Remarks

The virtual path of an application domain is similar to the virtual path of an application or virtual directory. A virtual path references only the significant portion of the path beyond the host identifier in a URL. For example, the default installation values for the default Web site specify a physical path of "C:\inetpub\wwwroot". When the default Web site is accessed through http://localhost/, the virtual path is "/".

Applies to