i want current browser URL (ex: http://localhost:1495/Global/General/SectionSetting) i have tried below code but i am getting API URL (ex: http://localhost:1495/api/Apiname/Functionname)
string sPagePath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
String baseUrl = Path.GetDirectoryName(HttpContext.Current.Request.Url.OriginalString);
Thanks in advance
In client and server disconnected architecture in asp.net Web API 2 I was used HttpContext.Header.Referrer
to get the client host information. This will just provide you the base absolute URL only. The browser relative path is not included on it.
From you question I can understand that you need the browser address on ajax request. One possible solution is to send the browser current url into api with ajax request. You can get the browser full url using javascript location
. For example
var absolutePath = window.location;
As I don't see your code, I just try to share my thoughts. Let's see if it's helpful for you. You can share your code to get better suggestions or solutions.
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.