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.
Related
I've added a custom header X-XSRF-TOKEN and when a user logs out I want to be able to remove that header from future requests sent by the browser.
In the logout web api action I can modify the header like so:
Request.GetOwinContext().Response.Headers.Append("X-XSRF-TOKEN", "ModifiedToken");
On future requests it now sends requests with the X-XSRF-TOKEN with the value ModifiedToken. Is there a way I can remove it instead. With cookies you can expire them.
If I call the remove function on the Request or Response headers, on the next request to the server the header is still present:
Request.GetOwinContext().Response.Headers.Remove("X-XSRF-TOKEN");
or
Request.GetOwinContext().Request.Headers.Remove("X-XSRF-TOKEN");
Is it even possible to do this or even guarantee the browser will actually stop sending the header?
Try This.
Request.GetOwinContext().Response.Headers.Append("NULL", "ModifiedToken");
Note - I am not sure it will work or not. But you can try this one as well.
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
I want to intercept the FormAuthentication 302 redirect code where it checks where a user is allowed to view a page or not and if he is not the module sends the user to '/login.aspx?ReturnURL="Requestedpage.aspx". I want to add custom query string here.
Edit: URL rewriting will not work for me. I want to intercept that code only. I want to set custom headers too from there.
Use URL Rewriting to set up a rule so that the URL /login.aspx?ReturnURL="Requestedpage.aspx is rewritten to whatever you require.
I have learned to use http request (create and Getresponse) methods to get the header and content of a link.
Problem is that, it is not the link that I want, that I get as http response.
There is an authentication page that comes instead. Only when I click the accept button, do I reach the page I want.
So the header and content that I actually get is of the authentication page.
Is there a way I can use this header and content to create ones more http request to get the page that I want?
I need to click the accept button in the background.
Thanks.
I'd recommend using Fiddler to capture the interaction with the site using a browser. You can then use the Fiddler output as a guide for replicating the same functionality using your code.
If the site is keeping track of whether or not each user has clicked the Accept button on a per-session basis you'll need to replicate that, probably with an HTTP POST. You'll be able to see how to construct that POST, if relevant, from the Fiddler output.
Can I make a Response.Redirect modifying the headers of that "request (¿) "
There is no way to send a redirect and make the browser add headers to its HTTP request for the page you redirected to.
However, look at Server.Transfer.