I am trying to create simple code to extract the string for the current url as follows:
string currentURL = HttpContext.Current.Request.Url.ToString();
However, I get an error when running the code: Object reference not set to an instance of an object.
I assume that I need to create an instance of HttpContext. The arguments for the HttpContext are either HttpContext(HttpRequest request, HttpResponse response)or HttpContext(HttpWorkerRequest wr).
Is there any documentation that details how to work with these arguments? I am new to C #, so Iām not quite sure how to instantiate this object correctly and did not find resources that were useful (including the MS library).
source
share