SharePoint Dragons

Nikander & Margriet on SharePoint

Determining the SharePoint server version from a client programmatically

The next bit was taken from a forum post and written by Wayne Fan:

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010general/thread/285ee634-2850-40cb-aec6-ace9297526a6

It’s a piece of code that issues a HTTP request and can be used for determining the version of SharePoint on a server. We’re documenting it here, because we know there’ll come a day that we’ll need this code:

HttpWebRequest request =(HttpWebRequest)WebRequest.Create(“http://<servername>/default.aspx&#8221;);

request.Credentials=new NetworkCredential(“<username>”,”<password>”,”<domain>”);

HttpWebResponse response =(HttpWebResponse)request.GetResponse();

request.Accept = “text/plain”;

Console.WriteLine(“Server Version:{0}”,response.GetResponseHeader(“MicrosoftSharePointTeamServices”));

When it’s a SharePoint 2010 site, you will get the result is like this: MicrosoftSharePointTeamServices: 14.0.0.6106

And in SharePoint 2007 site, the result is like this: MicrosoftSharePointTeamServices:12.0.0.4518

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 395 other followers

%d bloggers like this: