Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hallo evrybody ,

i am trying to make some operations simultaneously at the same time
per Ajax ,to search some data in Database,
but somehow it doesn't work , cause the server is treating each request individually !!

is that anyway possible ?

What I have tried:

File1.js
<pre lang="Javascript"><script>
$.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType:"json",
                    async: true,
                    cache:false,
                    data: "{myparameters}",
                    url: "myFunct"
                    success: callback

});
</script>

File2.js
<script>
$.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataType:"json",
                    async: true,
                    cache:false,
                    data: "myparameters",
                    url: "myFunct"
                    success: callback

});
</script>


VB
<WebMethod()> Public Shared Function myFunct (par1 as string) as string
//do some code here
end Function
Posted
Updated 7-Nov-18 1:39am
v2
Comments
j snooze 6-Nov-18 17:32pm    
wouldn't you just put the async in your method definition?
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/async/
Member 12785541 7-Nov-18 4:36am    
already try it before , but it didn't help !!

1 solution

The most likely issue is that you have session state enabled. Even if your method never touches the session state, if it's enabled for the request handler (the page), all requests to that handler with the same session ID will be serialized.

If possible, turn off session state for the page:
<%@ Page ... EnableSessionState="False" %>

If you need to read data from the session, you might be able to get away with making it read-only:
<%@ Page ... EnableSessionState="ReadOnly" %>

If other parts of your page need to write to the session, then you'll need to move the method to a separate handler, and disable session state for that handler.

If your method needs to write data to the session, then there's nothing you can do.

ASP.NET Session State Overview | Microsoft Docs[^]
 
Share this answer
 
v2
Comments
Member 12785541 7-Nov-18 7:47am    
i already set enablesession on False , but still not Async :
<webmethod(enablesession:=false)> Public Shared Function myFunct (par1 as string) as string
//do some code here
end Function
Richard Deeming 7-Nov-18 7:49am    
If the method is part of a page, you need to disable the session state for the entire page, not just for that method.
Member 12785541 7-Nov-18 7:55am    
Thnak you so much i make it readonly , and it works

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900