WebClient: How to set the host name (host header)? [duplicate] - c#

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");

Related

Including encrypted key in url [duplicate]

This question already has answers here:
How to achieve Base64 URL safe encoding in C#?
(10 answers)
Closed 4 years ago.
I have an encrypted url that gets passed in as a query string such as
myurl.com/key/cYtLPBlnOUOi+8413hTQLz+GGeoiLeLhbPuNhK+saqhc/f/FgtKSbcInVB9IIoWER71L1Q6vrnLv8o3eKI843|M==
I am having issues, I believe due to the special characters such as the forward slash. How can I accept this url?
Add a reference to System.Web (Project > References > Add reference > System.Web)
System.Web.HttpUtility.UrlEncode(YOUR_STRING);

Get URL Params with '#' [duplicate]

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 ?

Getting # value at the end of url in asp.net [duplicate]

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.

Find out from which url your API called [duplicate]

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.

Specify Custom IP in HTTPWebRequest [duplicate]

This question already has answers here:
how to change originating IP in HttpWebRequest
(2 answers)
Closed 9 years ago.
is it possible to change orginating IP in HTTPWebRequest C# and provide any Custom/fake IP?
You could try out the following Libraries
PCap.NET Referenced from IP address spoofing using PCap.NET
sharppcap Referenced from C# How to spoof IP address for WebRequest

Categories