0

I have a simple repeater inside an UpdatePanel in my ASP.NET page. This repeater has a button in every RepeaterItem than, when clicked, will redirect you to another page based on the information contained in that particular RepeaterItem. Nothing out of the ordinary until that point.

In my development computer when I click one of these buttons I get a response from the ajax call that looks like

"1|#||N|M|pageRedirect||/somepage.aspx?q=bla|" 

and everything works like it should. I'm guessing the script manager handles that directive and sends the browser via JS to somepage.aspx?q=bla.

When I deploy this to my actual website (dedicated server, I really try to keep the same configuration in both enviroments, including using IIS in my development computer) this behaviour changes. When I click on one these buttons I get a 302 Found response from the server and the HTTP headers include a

Location: /somepage.aspx?q=bla

directive. What ends up happening is that the browser (FF, chome, IE) handle both pages (meaning the ajax call and they do a GET from page I'm trying to redirect to) but only the original page is rendered, so no redirection takes place. The 2nd page is loaded but in "the background" and never shown.

I'm trying to found the reason behind these 2 different behaviours. From what I could find by googling around is that this might be a configuration error (for example, see this question) but my configuration is the same in both servers. Keep in mind that I cant mess around too much with the actual website so right now I'm trying to make my development server to act like the production server so I know where this difference is coming from and then take the proper actions.

Any help will be appreciated.

Community
  • 1
  • 1
Ed Fox
  • 173
  • 1
  • 9

1 Answers1

0

Sending a 302 redirect response back from an ajax request doesn't work because the redirect won't happen. So ASP.NET Ajax intercepts any redirect on the server side, converts it into a status code 200 and then it does the 'redirect' manually on the client side (using window.location).

For some reason the ASP.NET Ajax (ScriptModule) isn't converting your 302 response correctly when it's deployed. My best guess is that it doesn't think it's an ajax request - to decide whether it's an ajax request it looks to see if it contains a "X-MicrosoftAjax: Delta=true" header. Check to see if this header is being received on the server side of your deployed site.

graham mendick
  • 1,839
  • 1
  • 17
  • 15
  • Yes, the browser seems to be sending that information to the server (`X-Requested-With: XMLHttpRequest` and `X-MicrosoftAjax: Delta=true`) – Ed Fox Sep 09 '12 at 16:44
  • @EdFox You need to check that information reaches the server side, e.g., a firewall might strip it out – graham mendick Sep 09 '12 at 17:47
  • I'm accepting your response but I ended up registering clicks as triggers to force a full postback. I'm thinking this is a bug in either asp.net or telerik since I checked in the server and the headers are coming down ok. – Ed Fox Sep 30 '12 at 23:59