Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi , i am retrieving machine details using c# and wmi . i using following code to retrieve information:
C#
ManagementScope scope =new ManagementScope(@"\\"+strIPAddress+@"\root\cimv2");
SelectQuery query = new SelectQuery();
query.QueryString = "select  * from Win32_OperatingSystem";
ManagementObjectSearcher searcher =new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
 //////////////////////////////////
}


it is working fine for windows operating system. but it does not works for linux , Citrix server,

i have also tried this code :
C#
string strURL="http://www.google.com"; 

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
        try
        {
            HttpWebResponse response =(HttpWebResponse) request.GetResponse();
            string strServer= response.Server;           
        }
        catch (WebException wex)
        {
        // Safe cast to HttpWebResponse using 'as', will return null if unsuccessful
            var httpWebResponse = wex.Response as HttpWebResponse;
            if (httpWebResponse != null)
            {
                var httpStatusCode = httpWebResponse.StatusCode;
                // HttpStatusCode is an enum, cast it to int for its actual value
                var httpStatusCodeInt = (int)httpWebResponse.StatusCode;
            }
        }


but it does not gives me the remote server os name rather it gives me IIS name.

when i searched over internet, i found the following site:
http://uptime.netcraft.com/[^]


where anyone can retrieve information. can anyone tell how is it works or how we can fetch these details using c#.

Thanks,

Arshad
Posted

1 solution

WMI is a windows specific technology so you cannot use it with Linux etc.

Try the following article : Web Server Information using .NET[^]
 
Share this answer
 
Comments
arshad alam 13-Aug-12 0:26am    
@mehdi Golam, can you tell me how http://uptime.netcraft.com fetching details. i found that its in PHP.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900