0

I want to get current page url in c#. I have tried below code

_path = System.Web.HttpContext.Current.Request.Url.Host;

but I am getting error "Object reference not set to an instance of an object"

please help me in this. Thank you

AmrutaG
  • 43
  • 8
  • 2
    Possible duplicate of [What is a NullReferenceException and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Steve Feb 28 '16 at 08:25
  • I think this is already answered at another question. [Check this](http://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharp) – Qsprec Feb 28 '16 at 08:26
  • What is `null` here? – Shaharyar Feb 28 '16 at 08:27
  • Thank you all. I will go through the provided links – AmrutaG Feb 28 '16 at 08:34
  • Is there any other way instead of httpcontext to get the current page? – AmrutaG Feb 28 '16 at 08:46

0 Answers0