When I call Request.RawUrl I am not getting the domain name (at least in development).
For example, if my url locally is:
http://localhost:2343/some/thing
The call to Request.RawUrl is giving me back:
/some/thing
I recall it returns everything, is this the behaviour b/c it is local dev?
Update
I am also using Url Re-Writing so things like Request.Url.AbsoluteUri return back the internal url, not the re-written url that i need to get.
is javascript the only way then?
Or I maybe I can use Request.RawUrl for the url part, and then just get the domain name part somehow? (sometimes it has a port too...)
System. Web Http Request. Raw Url Property System. Web Gets the raw URL of the current request. The raw URL of the current request. The following code example uses the HtmlEncode method to HTML-encode the value of the RawUrl property and the WriteLine method to write the encoded value to the file.
To answer the question: Yes a website can make an HTTP request to localhost. It will not break cross domain policy, because the request will not cross domains. It will stay local. One way to avoid cross domain policies, is to get the target victim to make the HTTP request themselves.
However, the URL property of an HTTPRequest object returns a System.URI object, which also contains server name. Show activity on this post. Request.RawUrl is very similar to Request.Url.PathAndQuery except that Request.Url.PathAndQuery includes the Default Document if one was used whereas Request.RawUrl does not.
Request.RawUrl is very similar to Request.Url.PathAndQuery except that Request.Url.PathAndQuery includes the Default Document if one was used whereas Request.RawUrl does not. From my experience, this is true for ASP.Net 4.0 and higher.
According to the documentation:
The raw URL is defined as the part of the URL following the domain information. In the URL string http://www.contoso.com/articles/recent.aspx, the raw URL is /articles/recent.aspx. The raw URL includes the query string, if present.
You can use Request.Url.AbsoluteUri
to get the entire thing.
See what you get with Request.Url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With