SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not looking for the solution using SPContext & so. I tried it but I can't get URLs like: )
thanks george

ps: I forgot to mention that this is about a MS Sharepoint 2010 Visual Webpart and I'm programming in C#

share|improve this question
What is the context of your situation, are you in an ItemEventReceiver, WebPart, DataViewWebPart, etc? – James Love Sep 28 '10 at 14:25
Visual WebPart! and I'm looking for a solution in C#... – Anonymous Sep 28 '10 at 16:22

this.Page.Request.URL should give you the URL of the current HTTP request.

share|improve this answer
thank you so much! that's perfect & so simple! this.Page.Request.URL.AbsoluteUri works all the time & It's way less complicated than working with SPContext & stuff! cheers george – Anonymous Sep 29 '10 at 8:30
No problem, you're welcome. – Flo Sep 29 '10 at 8:45
FYI - This property can be used by all ASP.NET pages, not just SharePoint pages. – Russell Oct 17 '12 at 1:59

For a C# solution you could use HttpRequest.Url, that may get you the full current URL, or otherwise get the Url property form SPContext.Current.

share|improve this answer

You could use jQuery to get the path and display it.

$(document).ready(function() { var pathname = window.location.pathname; });

share|improve this answer

Lori's answer will work, but if you haven't already loaded jQuery to do something else then it's probably just a waste of overhead to load it just for this purpose.

You can grab it with straight JavaScript:

var theURL = window.location.pathname;
share|improve this answer
Thanx, but I forgot to mention that I'm looking for a solution in C#. JavaScript is nice but I dont want to use it because of ActiveScripting(could be disabled in some browsers)... – Anonymous Sep 28 '10 at 16:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.