5

I've got a autocomplete textbox requesting an IHttphandler via IIS7 written in C#.

But the requests that get to the webserver seems to arrive unorder.

Here is an example of the log I get from the IHttpHandler after typing 'guidolin'

406302 2010-11-24 12:33:58,448 [8256] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:guidoli RequestTime:24/11/2010 12:33:58(396)
406418 2010-11-24 12:33:58,564 [8256] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:guidolin RequestTime:24/11/2010 12:33:58(507) 
407751 2010-11-24 12:33:59,897 [8256] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:gu RequestTime:24/11/2010 12:33:58(685) 
408008 2010-11-24 12:34:00,154 [8256] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:guid RequestTime:24/11/2010 12:34:00(56) 
408167 2010-11-24 12:34:00,313 [8000] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:guido RequestTime:24/11/2010 12:34:00(244) 
408562 2010-11-24 12:34:00,708 [5912] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:gui RequestTime:24/11/2010 12:34:00(368) 
408832 2010-11-24 12:34:00,978 [8000] DEBUG Services.jQueryHandler  - VALID jQueryHandler request data:guidol RequestTime:24/11/2010 12:34:00(946) 

So obviously, the request doesn't arrive in the right order. Did any one already face this problem or does someone know a workaround about it ?

Here is the jQuery code for the autocomplete:

textBox.autocomplete({
  source: textBox.attr("data-handler-url"),
  select: function (event, ui) {
    textBox.next("input[type='hidden']").val(ui.item.objectId);
    textBox.data('selected-value', ui.item.value);
  }
});
Rup
  • 33,765
  • 9
  • 83
  • 112
Pitming_Reloaded
  • 541
  • 2
  • 5
  • 12
  • What's your jQuery code look like? Are you doing anything special with it? – David Hoerster Nov 24 '10 at 13:43
  • no, it's just requesting IHttphandler like this: – Pitming_Reloaded Nov 24 '10 at 13:57
  • Are you sure it's a problem on the server side and in any case does it matter? When the site is heavily loaded I doubt you could guarantee requests get dealt with in the 'right' order. – Rup Nov 24 '10 at 14:02
  • textBox.autocomplete({ source: textBox.attr("data-handler-url"), select: function (event, ui) { textBox.next("input[type='hidden']").val(ui.item.objectId); textBox.data('selected-value', ui.item.value); } }); – Pitming_Reloaded Nov 24 '10 at 14:04
  • @Rup I don't think it has something to do with heavy load 'cause i'm testing on my own develeoppement machine – Pitming_Reloaded Nov 24 '10 at 14:05
  • 2
    Sure, I meant that when you do have a production system under heavy load you're even less likely to have any guarantees about processing order - so it's not something you can rely on and, whilst this case is odd, it shouldn't be cause for concern. – Rup Nov 24 '10 at 18:16
  • I waw wondering if maybee an httpmodule could mix the order of the request ? – Pitming_Reloaded Nov 25 '10 at 10:25

1 Answers1

0

This is HTTP, by definition a stateless protocol. There is no concept of "order" in HTTP; everything starts with a request message. You cannot code your application in such a way as to expect or require that requests have any kind of logical order; after all, it is the clients that are choosing to send the requests. Only the physical order in which they arrive matters.

In your example, who's to say the client didn't type guidolin, then change it to gu?

To answer your question, there is no workaround for this issue because it is a non-issue. Program your application so that it doesn't care about the "order" in which these messages arrive, if possible.

NathanAldenSr
  • 7,841
  • 4
  • 40
  • 51