Hey!
I working on a hotel search engine with gathers the result from a API of Expedia
I am displaying the first 15 results and then I am starting a async function to save the rest of the results in a database.
Async Function RequestMoreHotels(ByVal city As String, ByVal country As String, ByVal countryCode As String, ByVal RegionID As String, ByVal checkInDate As String, ByVal CheckOutDate As String, ByVal NrOfRooms As String, ByVal Room1 As String, ByVal Room2 As String, ByVal Room3 As String) As Task(Of JsonResult)
ReqCountry = Server.HtmlEncode(country)
ReqCity = Server.HtmlEncode(city)
ReqcountryCode = Server.HtmlEncode(countryCode)
ReqRegID = Server.HtmlEncode(RegionID)
ReqArrival = Server.HtmlEncode(checkInDate)
ReqDeparture = Server.HtmlEncode(CheckOutDate)
ReqRoomsRequested = Server.HtmlEncode(NrOfRooms)
ReqRoom1 = Server.HtmlEncode(Room1)
ReqRoom2 = Server.HtmlEncode(Room2)
ReqRoom3 = Server.HtmlEncode(Room3)
RebelCurrency = Session("Currency")
If Session("Culture") = "de" Then
LangSetting = "de_DE"
Else
LangSetting = "en_US"
End If
UserSession = Session("UserSessionID")
Await GetAsyncHotelsAsync()
Return Json("done", JsonRequestBehavior.AllowGet)
End Function
Async Function GetAsyncHotelsAsync() As Task
get more results and save them in a database
End Function
So, this is working fine.
But when in the meantime (while the above function is running) the user requesting more results
(ajax request:
Public Function GetNextResults() As JsonResult
Dim GetHotels = (From gh In _db2.temp_hotels Where gh.Session = UserSession And gh.shown = False Order By gh.ID Descending Select gh).Take(20).ToList
Dim HotelHtml As New StringBuilder
For Each item In GetHotels
HotelHtml.Append("make the HTML")
Next
Return Json(New With {.element = HotelHtml.ToString, .moreresults = MoreResults}, JsonRequestBehavior.AllowGet)
End Function
and this request is pending a long time and when it is finally executed, the UserSession is nothing.
It would be awesome if someone of you can help me with that
Thanks in advance
Cheers