http response and response.redirect simultameously in classic asp - asp-classic

I am having an asp page(Sendxml.asp) which post an xml to another asp page (Receivexml.asp). On ReceiveXML.asp, I process the xml and send back the http response to SendXML.asp page and this works fine.
Now i have a situation where I have to send back the http response from ReceiveXML.asp to SendXML.asp but also i have to redirect the user to another url (page) from ReceiveXML.asp page.
Could any one please help me to achieve this.

You can't make a redirect in ReceiveXML.asp as that page is only returning data to SendXML.asp.
You can only return one response for each request, and a redirect is also a form of response. Also, even if you return a redirect from ReceiveXML.asp that would only affect what is returned to SendXML.asp, it doesn't affect what SendXML.asp returns to the browser.
To redirect the user you have to do that in SendXML.asp.

Related

How do I redirect a GET with query string as a POST with formdata

Technologies in use:
Servlet 4.0 (provided by Tomcat 9)
Java 8
I am working with a commercial vendor's front end and am limited to sending GET requests from that front end.
There is information in the request that I do not want them to alter accidentally (and more than 1 user has so far) by changing the values in the query string of that request.
My idea was to redirect the GET request through a Servlet where I could remove the query string so they won't edit it, and submit it as a POST with formdata instead so that I can still get the data.
I cannot modify the page which sends the request, as it is vendor-provided software.
The query string with GET was previously done to get around this limitation, and if we had full control over this front end, we would simply change it to a POST with formdata.
Can I perform this redirect to avoid creating a more complicated landing page from the vendor's front end?
I've looked into forwarding, but that won't change the URL.
I've looked into sending a request from a page in the middle and returning the response, but that won't change the URL.
I've looked into Javascript embedded in a JSP that submits a hidden form, but that will possibly cause issues under load.
I'm hoping there is a simple way to redirect with a modified request object from inside a Servlet, but I haven't found anything.
example request from the user currently:
method: GET
URL: http://www.your.domain.com/service-get-or-post?field1=foo&field2=bar&field3=42
desired new target:
method: GET
URL: http://www.your.domain.com/service-trampoline?field1=foo&field2=bar&field3=42
desired new redirect:
method: POST
content: application/x-www-form-urlencoded
URL: http://www.your.domain.com/service-get-or-post
body: field1=foo&field2=bar&field3=42

Proxy aspx page

I have to create an aspx page that behind the scene will create a http request to another aspx page that's on a different domain and will return this content back to the user.
Is it good if I make an http web request in the 'PAGE_LOAD' event and then continue with: Response.Clear() to clear page default response and then Response.Write() where I will write the response from the http web request to the crossdomain page ?
I'm looking to know if this is a good way of replacing the initial response body.
Thanks

Can I do a http post and then redirect?

I'm trying to understand this properly.
I have a simple web form which, in the page load, I have a bit of code that creates a HttpWebRequest object. This then performs a Http POST passing some info in the body.
The response passes back a 302 redirect just fine. How would I redirect to the location page from the response in the page load? If I did a Response.Redirect would that being doing a HTTP GET again?
In addition, some of the info I pass in the post body will determine if I can even access the page that it wants to redirect. What's stopping someone getting the location URL and just pasting that in the browser and essentially doing a HTTP GET as well?
It is a little confusing and I may not be grasping it correctly and would love some insight.
How would I redirect to the location page from the response in the page load?
Sow the code that makes the request. You'll have to read the redirect location from the response and see MSDN: How to: Redirect Users to Another Page.
If I did a response.redirect would that being doing a get again?
Yes.
Whats stopping someone getting the location URL and just pasting that in the browser and essentially doing a get as well?
If you mean the "location" header from the 302 response to the POST you make in your Page_Load: your server will perform this POST request, not the client's browser. So they won't see this request or the URL it points to.
However, if you redirect them to the location the 302 response to the POST is pointing to, then their browser will go there anyway.

Spring MVC redirect returning RedirectView doesn't allow src image link to load

When Spring MVC does a redirect, should the page redirected to be able to process embedded src attributes that hit a server to fetch an image, as if loading a page for the first time? It works correctly when accessed via a link on a web page. Is redirect different than loading a new page via a link? My understanding was that redirect should load a page completely, resolving all references, similar to the way it does when navigating to it via a link on a web page. Is my understanding incorrect?
An HTTP response known as a redirect looks like this
HTTP/1.1 302 Found
Location: http://www.yourhost.com/some-page
Connection: close
That's it. When your browser receives this response, it will send a new HTTP GET request to the URI in the Location header.
Your error is somewhere else.

Response.Redirect vs Server.Transfer - redirect as a "suggestion"

So I read an article on Response.Redirect that say's "its like a suggestion" as compared to Server.Transfer which happens whether the client wants to or not. What does this mean? Is there some kind of event that we can offer a user to say "well nope nm I don't want to redirect to that page"?
Server.Transfer will execute the new page immediately and send its result to the client.
The client stays at the original URL doesn't see anything unusual.
Response.Redirect sends a special code, called an HTTP 302, that tells the client to send a new request to a different URL.
Response.Redirect
Response.Redirect will navigate to the url specified.
From MSDN
Any response body content such as displayed HTML text or Response.Write text in the page indicated by the original URL is ignored. However, this method does send other HTTP headers set by this page indicated by the original URL to the client. An automatic response body containing the redirect URL as a link is generated. The Redirect method sends the following explicit header, where URL is the value passed to the method, as shown in the following code:
Server.Transfer
Server.Transfer will execute the url passed in but maintain the url transfered from.
From MSDN
When you use the Transfer method, the state information for all the built-in objects are included in the transfer. This means that any variables or objects that have been assigned a value in session or application scope are maintained. In addition, all of the current contents for the Request collections are available to the .asp file that is receiving the transfer.
Here's an article discussing and comparing the two.
It's "like a suggestion" in the sense that when the client requests a url that's redirected, the server responds with "that object has moved...find it here." When you do Server.Transfer, you immediately respond with the output of the page to which you're transferring.
There's nothing in either process you could hook into to give the user any choice...you'd have to respond with a 200 and implement the choice to the user through logic.
Response.Redirect involves a "roundtrip" to the server whereas Server.Transfer conserves server resources by "avoiding the roundtrip". It just changes the focus of the webserver to a different page and transfers the page processing to a different page.

Resources