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

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.

Related

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

http response and response.redirect simultameously in classic asp

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.

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.

HTTP 302 redirect with full HTML page in the payload

Why would a site respond with an HTTP 302 (redirect) and include HTML in the payload. Check out godaddy.com. You will need an account to log in. When you log in you will see in an HTTP trace (I use firebug), a 302 returned with the location: header as expected, however the payload includes the complete HTML page. Next, as expected, you see the URL from the location header fetched with the same HTML payload. Why would they do that?
I don't know anythign about GoDaddy but it may be a way to somewhat post information back to their server but not force your browser to do an "auto form post". I'm working with ADFS currently and with that security (and many others) the authentication authority sends back a 200 with html of a form, which when loaded immediately posts that form to your server.
I'm currently experimenting with sending back a 302 with the payload that redirects back to the server instead. This prevents a flash of white as that auto-post is taking place.
It's just a guess :)

Handling HTTP 404 bad request error in asp.net

I am currently building a website and I want to add the HTTP 404 not found Error page. I designed the bad request page and its link is this, for example:
www.mysite.com/badr.cshtml
The problem is, I want to show the contents of this page on every invalid request without redirecting to that link. For example, if I type www.mysite.com/noexistingpage, the contents of badr.cshtml should load without redirecting to it.
And for your information, I am using Webmatrix2.
you do this via the web.config and the custom errors section.
http://www.localwisdom.com/blog/2010/08/how-to-setup-custom-404s-for-iis-and-asp-net-through-web-config/

Resources