This question already has an answer here:
Get URL of Referer page in ASP.NET
(1 answer)
Closed 8 years ago.
I'm using web api.My question is: I have to check from where call is coming in Global.asax(Application_AcquireRequestState) because I have to restrict some calls which are coming from unknown urls for the purpose of web api security.
You can use Request.UserHostAddress to get the IP address from which the call is coming and Request.UrlReferrer to get the URL that linked to the current URL.
Related
This question already has an answer here:
ASP.NET page POST only access
(1 answer)
Closed 3 years ago.
I am using asp.net web form.I am giving my page's url(www.domainname.Test.aspx) to client.I want client should send data by post method only,how to do that?
Which is best content type for this?
answered here https://stackoverflow.com/a/32326741/2122217
on Page_Load
if (!string.Equals(Request.HttpMethod, "POST"))
{
Response.StatusCode = 405;
Response.End();
}
This question already has answers here:
Retrieving anchor link in URL for ASP.NET
(3 answers)
Closed 8 years ago.
I have a url that receive request with parameters set like this from the return URL of the GoogleAuth. :
LoginReturn.aspx#state=/profile&access_token=token&token_type=Bearer&expires_in=3600
Because of '#' (instead of '?'), if I look in Request.QueryString or Request.RawUrl, there is no parameter and I need to get this access_token.
What is the correct way to get those parameters ?
Thanks for your help !
Everything that follows # is only for the browser. It's usually used to navigate to an anchor in a page, or for single page applications.
The correct way is to edit your query from # to ?
This question already has answers here:
How to get "Host:" header from HttpContext (asp.net)
(4 answers)
Closed 8 years ago.
I want to get datas from an html file on my asp webserver, in Javascript to get actual host we can use the following:
~/mydatas.php
It gives on localhost: "http://localhost/mydatas.php"
I want the same thing but in C# can you help me?
Thanks you.
You could also search in stackoverflow and you will find a lot of answered question which had the same problematic than you. Like this one
Hopes it will help you !
Edit : You can use
HttpContext.Current.Request.Url.AbsoluteUri
It will give you the URL of your web page.
I've already try
HttpContext.Current.Request.Url.Host
which gives on localhost
:\windows\system32\inetsrv\localhost
...
This question already has answers here:
Request Web Page in c# spoofing the Host
(9 answers)
Closed 8 years ago.
How can I set a Host header value with WebClient that is different than the one I use in the URL? For example, in
webClient.OpenRead("http://192.168.10.10/");
the host header value would be "192.168.10.10" but I want it to be something different (e.g. "example.org").
The address must have URL format
webClient.OpenRead("http://192.168.10.10");
This question already has answers here:
How to get Url Hash (#) from server side
(6 answers)
Closed 9 years ago.
How to get the value after # in the following url:
www.google.com/trian/test#dummyvalue
I am using ASP.NET and C#
A web browser won't pass this value back to the server. So in a typical scenario with a user on their computer accessing your website. The "fragment" portion of the url won't be supplied to the server. Therefore, your asp.net code can not access it. If you change your code to put this data in the querystring, then you can access it server side from asp.net.