ASP.NET Ajax - Asynch request has a separate session?

We are writing a search application that saves search criteria in session state and searches inside the asp.net update panel. Sometimes, when we perform several searches in series, the second or third search sometimes returns the results of the first set of search criteria.

Example: our first search, which we look at "John Smith" → John Smith results are displayed. The second search we are viewing on the pages "Bob Jones" → John Smith is displayed.

We save all search criteria in the session state, as I said, and read it from the session state inside the ajax request to format the database request. When we set breakpoints in VS, everything behaves as usual, but without them we get the original search criteria and results.

My hunch is that they are saved in the session, so that the ajax request somehow gets its own session and saves the criteria for this, and then extracts the criteria from this session each time, but material not related to asynchronous taxing can see when the criteria are changed and accordingly save the changes in the state, but since they consist of two different sessions, there is a discrepancy in what is stored and read.

EDIT: To clarify, it was suggested that search criteria be added to the query string, which is usually good practice, and I agree on how it should be, but following our requirements. I do not consider it viable. They want the user to search for input elements and there is no page reload, the only thing they see is the progress indicator on the page, and they still have the ability to navigate and use other functions on the current page. If I were to add criteria to the query string, I would have to execute another query, causing the entire page to load, which, depending on the search criteria, can take a very long time. That's why we use the ajax call to do the search and why we don't call another request for the full page ..... I hope this clarifies the situation.

+5
4

ASP.NET, ASP.NET AJAX. .

, , TextBox? - , , .

, ... UpdatePanel , , . . , .

- , . , , , :

- ( , UpdatePanel): http://encosia.com/2008/02/05/boost-aspnet-performance-with-deferred-content-loading/

JSON ( ): http://encosia.com/2008/06/26/use-jquery-and-aspnet-ajax-to-build-a-client-side-repeater/ p >

, , UpdatePanel.

+4

, ajax , PageMethods. , . UpdatePanel , , "" .

: ? , , - , ? , 2-/3- ? , , ajax, ( , ). , webfarm?

# 2: , ( ), , : https://stackoverflow.com/users/60/dave-ward

+5

EnableSession WebMethod , .

[WebMethod( EnableSession=true )]
public static void DoSomething(){
    /// ....
}
+4

If you use common .ashx handlers, just infer IRequiresSessionState from the interface

public class ActionRequest : IHttpHandler, IRequiresSessionState
{
}
0
source

All Articles