I might be approaching this issue the wrong way, but I am in need of knowing either the current URL of the current ASP.NET page or the form name.
I have a C# application with a WebBrowser which runs the ASP.NET application. Whenever I check the current URL in the WebBrowser component it always says it's the 'Default.aspx' page. Which is fine when you're running it in another browser, but I am in need of knowing the exact URL or the form.
I've also tried creating a javascript function to return the current URL, but since this function is only added to the 'default.aspx' page (so all the pages can access this function) I only get returned the 'default.aspx' URL.
Any ideas?
Thanks!
Edit: I forgot to mention that I use WCF events binded through net.tcp. When the ASP.NET application receives such an event, it should handle differently based on the current page it's on. I am not able to use Request or HTTPContext.Current, since there are NULL is my case.
Try below
private string GetCurrentURL()
{
string appPath = Request.ApplicationPath.ToString();
string[] strPath = Request.RawUrl.ToString().Split('/');
if (strPath.Count() == 2)
{
return Request.RawUrl.ToString().Replace(appPath, "")
}
else
{
return Request.RawUrl.ToString().Replace(appPath, "").Substring(1));
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.