How to find HTTP request details - c#

I want to redirect from www.abc.com to www.xyz.com.
When I redirectd to www.xyz.com at that time how I know about details of GET method of HTTP . so that I come to know this request come from www.abc.com.
As both application hosted on different sever. I tried HTTP Handler for www.xyz.com, but I am unable to get details of HTTP when request method is GET. My handler and module event unable to call at time of redirect.

You can pass hint, for example a parameter saying returnURL=abc.com.
And in the XYZ.com, check for the URL parameter.

Usually when you redirect the request, your header will have the Referrer information which can be retrievable from the target server. For more details about HTTP Referrer please click here

Related

How to find the request sender Url in my controller action?

I'm using Asp.Net MVC. I want to know the url from which a request has been sent to my controller action.For example my controller action is(Customer/Index) and I want to get the url from which, my action is called.(I don't need the current URL).I want the source URL from which the request sent to me. Is there any solution?
You could try using url referrer e.g.
Request.UrlReferrer
Request.QueryString["Referrer"].ToString()
Have a look at this link: MDN reference
It states that "A Referer header is not sent by browsers if: The referring resource is a local "file" or "data" URI."
If you want to have that available if your page calls 'itself' i.e. another page/controller in you web application, you can try to add the header manually on a per request basis.

Get final redirect URL

I am writing a code to get through authentication to a API based web site. I have the API key that the site needs during the login process. When I call the login method with the API key, it is supposed to redirect to a predefined URL whose parameter will then contain the request token.
e.g on firing the URL in the browser,
https://kite.trade/connect/login?api_key=hcwmefsivttbchla
I am redirected to
https://impacted-purposes.000webhostapp.com/?status=success&request_token=nb0vrfota9ott1r02q153pk3422joruf
(The request token will change in every run)
Notice the request token in the URL on the redirected URL. That's what I need to get from the code.
So, I use a the code that is referred here GetFinalRedirect:
Getting the Redirected URL from the Original URL
ie. I call:
GetFinalRedirect("https://kite.trade/connect/login?api_key=hcwmefsivttbchla")
However, I don't get the final redirect. I understand there could be a Javascript redirect, but checking the response, doesn't suggest so.
Any help pls to get the final URL so that I can parse the request token from it.
Well, I can't test this since i don't have an account. And I hope thats not your real-api-key...
But the function you're using is just sending a HEAD request to server. A HEAD request has no response. With the HEAD request you will only get redirects that are included in the HTTP headers. If the redirect is done with HTML-META tags or with javascript you have to send a GET (or POST) request...
If that fails too set a breakpoint inside the function and look at the received http-headers and the response text...

How to make http get request\response to site?

I am new at web development, so how to make http request\respone for some site (http://google.com)
Thank you!
P.S.
I mean, that when my SomeController activated- i want send http request to another site,get data from it and send it into View
A client (browser) submits HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and also contains the requested content. GET - requests data from a specified resource, http://google.com - you type this url in browser and hit the enter key, it's a get request and you see a page, that the response.
Click here for details.
Use HttpClient to connect a site from your mvc controller, click here for details.

MVC Redirect with headers

In an action method I want to redirect to a third party url. They collect some info from custom headers.
I have understood that I can not redirect the user, for example:
return RedirectResult(some url);
since the browser will not reattach my custom headers..
How do I do this? Is this a wrong approach?
They collect some info from custom headers.
So you can't redirect. You need to read their documentation. You're most likely expected to do an HTTP request to their server and show the user the response.

Redirect and pass form variables

I am integrating with a 3rd party payment platform (Stripe). Their API is posting back a bunch of parameters in the HTTP post to an aspx page. What I need to do is read one of the FORM variables to know where the post should be forwarded to (i.e. it needs to be redirected to the user specific subdomain endpoint - https://user1.mayapp.com/newstripeaccount.aspx).
My questions is how in .NET can you forward the request and preserve all the http post parameters without meticulously parsing them out and using HttpWebRequest to construct a new HTTP post to the final endpoint. Is there a simpler way to redirect and just pass the httpcontext?

Categories

Resources