I have the following problem:
I am currently implementing AJAX (Asynchronous Javascript And Xml) into certain areas of my website. Anyway - it uses the JavaScript XmlHttpResponse object to send and receive data to and from the server without having to post back the page.
Everything is working great, until I try to use a Response.Redirect() on the server side.
Here is my example:
I have a content page which is access restricted to registered users, and this is how it SHOULD work:
1. The page (RestrictedPage.aspx) loads an empty template.
2. Once loaded, I use the JavaScript XmlHttpResponse object to fetch content to fill the template (without reloading the page). I request data from, lets say, content.aspx
3. content.aspx first checks to see that the user is logged in
- 3.1) Not logged in - it redirects to an appropriate page to output the "access denied" XML
- 3.2) Logged in - Redirects to appropriate page to output XML content
4. Now the info is returned to the XmlHttpResponse object on the client side (RestrictedPage.aspx).
5. I use JavaScript to work with the XML, and do appropriate things depending on what the returned XML is... (like tell the user to log in, or use DOM objects to fill the template with content)
All of this works great WITHOUT redirects involved. My problem is that as soon as I use Response.Redirect() in step 3.1 or 3.2 above, instead of just the XmlHttpResponse URL redirecting, the actual client is redirected, and the browser loads what should be loading in the XmlHttpResponse object...
I have a feeling there is no work around, but if anyone knows why this happens, please let me know!??
Thanks!
I am currently implementing AJAX (Asynchronous Javascript And Xml) into certain areas of my website. Anyway - it uses the JavaScript XmlHttpResponse object to send and receive data to and from the server without having to post back the page.
Everything is working great, until I try to use a Response.Redirect() on the server side.
Here is my example:
I have a content page which is access restricted to registered users, and this is how it SHOULD work:
1. The page (RestrictedPage.aspx) loads an empty template.
2. Once loaded, I use the JavaScript XmlHttpResponse object to fetch content to fill the template (without reloading the page). I request data from, lets say, content.aspx
3. content.aspx first checks to see that the user is logged in
- 3.1) Not logged in - it redirects to an appropriate page to output the "access denied" XML
- 3.2) Logged in - Redirects to appropriate page to output XML content
4. Now the info is returned to the XmlHttpResponse object on the client side (RestrictedPage.aspx).
5. I use JavaScript to work with the XML, and do appropriate things depending on what the returned XML is... (like tell the user to log in, or use DOM objects to fill the template with content)
All of this works great WITHOUT redirects involved. My problem is that as soon as I use Response.Redirect() in step 3.1 or 3.2 above, instead of just the XmlHttpResponse URL redirecting, the actual client is redirected, and the browser loads what should be loading in the XmlHttpResponse object...
I have a feeling there is no work around, but if anyone knows why this happens, please let me know!??
Thanks!