Sunday, February 3, 2013

Get SharePoint Web Application URL and path programmatically

Sometimes you may would like to get the URL of the SharePoint web application. Assume that you have a web application created but yet you have not created the site collection.

There may be a case to get the URL and even sometimes the port on which your web application is running programmatically.

You do not get these information directly via SPWebApplication object property. You can get this like shown below.

Hope this helps.

No comments:

Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to