Salve,
ho scritto, si fa per dire, per lo più ho ricopiato da altre applicazioni asp alcune righe di codice per valutare il comportamento di aspnet dovendo traslare le suddette applicazioni verso aspnet.
Ho adattato il file global.asa di asp in un file global.aspx.
poi ho scritto una paginetta di prova default.aspx che eseguisse una semplice operazionecodice:<%@ Application Language="VB" %> <script runat="server"> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs on application startup Application("ActiveUser") = 0 End Sub Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs on application shutdown End Sub Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when an unhandled error occurs End Sub Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started Application.Lock() Application("ActiveUser") = Application("ActiveUser") + 1 Session("IDSessione") = Session.SessionID DBAccess(Session("NewID"), "S") Session.Timeout = 18 Application.UnLock() End Sub Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a session ends. ' Note: The Session_End event is raised only when the sessionstate mode ' is set to InProc in the Web.config file. If session mode is set to StateServer ' or SQLServer, the event is not raised. Application.Lock() Application("ActiveUser") = Application("ActiveUser") - 1 DBAccess(Session("NewID"), "E") Session.RemoveAll() Application.UnLock() End Sub Sub DBAccess(ByVal SS, ByVal SE) Dim odb As TOLPPServerNet.coDBAccess, sqlString As String = "", rs As Int32 = 0 odb = New TOLPPServerNet.coDBAccess odb.NomeFileIni = System.Web.Hosting.HostingEnvironment.MapPath("\t3\bin\") & "toldbini.ini" odb.InitClass("192.168.1.50", "192.168.1.50") odb.DBServer = "192.168.1.50" odb.DBName = "GIIETAC" rs = odb.opendatabase("GIIETAC", "sa", "") If SE = "E" Then odb.ExecuteCommand("Delete from Tol2006..TolPostiSelezionati where IDPP=" & SS, Nothing, NetIDBAccess.IDBAccess.IDBAccess.DBCmdType.CmdUnknown) odb.ExecuteCommand("Delete from GIIETAC..tblOnLineSessione where IDSessione='" & SS & "'", Nothing, NetIDBAccess.IDBAccess.IDBAccess.DBCmdType.CmdUnknown) ElseIf SE = "S" Then Dim iRnd As Int32 = CType(Format(Date.Now, "hhmmssfff"), Int32) Randomize(iRnd) Session("rnd") = iRnd Dim NewID As Int64 = Rnd() * 1.0E+15 Session("NewID") = NewID sqlString = "Insert into GIIETAC..TblOnLineSessione values('" & NewID & "',getdate())" odb.ExecuteCommand(sqlString, Nothing, NetIDBAccess.IDBAccess.IDBAccess.DBCmdType.CmdUnknown) sqlString = "Insert into GIIETAC..TblUserTrace values('" & Request.Servervariables("REMOTE_ADDR") & "','" & Request.Servervariables("HTTP_USER_AGENT") & "',getdate())" odb.ExecuteCommand(sqlString, Nothing, NetIDBAccess.IDBAccess.IDBAccess.DBCmdType.CmdUnknown) End If odb = Nothing End Sub </script>
il codice della pagina
Tralasciando il funzionamento delle due librerie referenziate in entrambi gli script, che sicuramente funzionano essendo state abbondantemente testate con diverse applicazioni dotnet, riporto quello che risulta dal file di log scritto dalla libreria "TOLPPServerNet"codice:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Import Namespace="TOLPPServerNet" %> <%@ Import Namespace="CDataAccess" %> <% Dim myDBAccess As TOLPPServerNet.coDBAccess = New TOLPPServerNet.coDBAccess Dim myRS As CDataAccess.DataAccess = Nothing Dim RetVal As Object = Nothing dim IDSessione as string="" Try 'myDBAccess.InitClass("", "") myDBAccess.NomeFileIni = (Server.MapPath("\t3\bin\")) & "toldbini.ini" Response.Write(Server.MapPath("\t3") & "<br>") Response.Write(myDBAccess.NomeFileIni & "<br>") If myDBAccess.OpenDataBase("Tol2006", "sa", "") Then if Session("IDSessione")="" then Session("IDSessione")=myDBAccess.SessionID else myDBAccess.SessionID=Session("NewID") end if Response.Write("DB Opened<br>" & Session("IDSessione") & "<br>" & Session("NewID") & "<br>") response.write(Session("rnd") & "<br>") If myDBAccess.OpenRecordset("Select * from tolanagraficautente", Nothing, Retval) Then Response.Write("OpenRecordset<br>") If IsArray(RetVal) Then myRS = New CDataAccess.DataAccess Dim cdo() As Object = CType(RetVal, Array)(0, 3) Dim fdo As Int16 = CType(RetVal, Array).GetUpperBound(0) + 1 myRS.SetDataAccess(CType(RetVal, Array), fdo, cdo.Length) Dim i, j As Int16 Response.Write("<table cellspacing=1 border=0>" & ControlChars.CrLf) For i = 1 To myRS.RowCount Response.Write("<tr>") For j = 1 To myRS.FieldCount Response.Write("<td>" & myRS.ValoreRecord(j, i) & "</td>") Next Response.Write("</tr>" & ControlChars.CrLf) Next Response.Write("</table>" & ControlChars.CrLf) End If End If End If Catch ex As Exception Response.Write(ex.ToString) End Try %>
Come si vede dalla sequenza delle chiamate effettuate subito dopo che la sessione è stata startata e la richiesta di accesso alla base dati è stata soddisfatta viene eseguito il codice di chiusura della sessione.codice:2014-09-29 03.58.44.687 20140929155844343 - [ExecuteCommand Insert into GIIETAC..TblOnLineSessione values('349804103374481',getdate())] () 2014-09-29 03.58.44.843 20140929155844343 - [ExecuteCommand Insert into GIIETAC..TblUserTrace values('192.168.1.30','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)',getdate())] () 2014-09-29 03.58.44.937 349804103374481 - [OpenRecordset Select * from tolanagraficautente] () 2014-09-29 03.58.46.093 20140929155846078 - [ExecuteCommand Delete from Tol2006..TolPostiSelezionati where IDPP=349804103374481] () 2014-09-29 03.58.46.125 20140929155846078 - [ExecuteCommand Delete from GIIETAC..tblOnLineSessione where IDSessione='349804103374481'] ()
Ho cercato da diverse parti ma non ho trovato nulla che mi chiarisse le idee.
Premetto che lo stesso codice in formato asp funziona correttamente (ovviamente le librerie richiamate non sono le stesse, ma hanno le stesse funzionalità).
C'è qualche buon samaritano che mi dia le giuste indicazioni o che dica dove è l'errore.
Grazie

Rispondi quotando
saro' io...
