Hello,
I have a weird bug on a asp.net project I'm working on.
I have some session variables in the app that work perfect and I didn't have much trouble with them untill now. We're using Visual Studio 2008 and wcf.
The problem is that session variables are working properly everywhere, but there is one MasterPage where suddenly all the session variables sets automatically to nothing. I'll paste some code below.
This is the last thing done before triggering again the failing MasterPage:
''' <summary>
''' Procedimiento que elimina de la BD la carpeta seleccionada.
''' </summary>
''' <remarks></remarks>
Public Sub carpetaEliminar()
Dim lstCarpetas As New List(Of Entidades.clsCarpetaEstructura)
Dim strMsj As String = "Error al eliminar la carpeta."
Dim aValue As String()
Try
aValue = trvCarpetas.SelectedNode.Value.Split(CType("|", Char))
'Sólo los administradores y controladores totales pueden eliminar carpetas de estructura y de organización
If (Not (Session("idPermiso").ToString = "5" Or Session("idPermiso").ToString = "1")) And (aValue(3) = "1" Or aValue(4) <> "0") Then
strMsj = "Las carpetas de estructura y de organización no se pueden eliminar."
Response.Redirect("../../../Mensaje.aspx?msj=" & strMsj & "&tp=0")
Else
lstCarpetas = subcarpetasObtener(trvCarpetas.SelectedNode, lstCarpetas)
wcfSrvGECOB21CarpetasObra.CarpetasEliminar(lstCarpetas, Session("idObra").ToString)
EstructuraTreeViewCrear()
phColumnaCarpeta.Visible = False
End If
Catch ex As Exception
Response.Redirect("../../../Mensaje.aspx?msj=" & strMsj & "&tp=0")
End Try
End Sub
Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
wcfSrvGECOB21CarpetasObra.Abort()
wcfSrvGECOB21CarpetasObra.Close()
wcfSrvGECOB21CarpetasObra = Nothing
End Sub
When this process finishes the variables are still active.
This is the MasterPage code. It only fails after processing the above code :
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim strRedireccionar As String = "../../../Mensaje.aspx?msj=Usuario no identificado.&tp=5&dir=http://www.mywebsite.com/DefaultApp.aspx"
Dim strRedireccionarObra As String = "../../../Mensaje.aspx?msj=Debe seleccionar una obra con la que trabajar.&tp=0"
Try
If IsNothing(Session("idUsuario")) Then
Response.Redirect(strRedireccionar)
ElseIf Session("idUsuario").ToString = "" Then
Response.Redirect(strRedireccionar)
ElseIf IsNothing(Session("IdObra")) Then
strRedireccionar = strRedireccionarObra
Response.Redirect(strRedireccionar)
ElseIf Session("IdObra").ToString = "" Then
strRedireccionar = strRedireccionarObra
Response.Redirect(strRedireccionar)
End If
accesosValidar()
Catch ex As Exception
Response.Redirect(strRedireccionar)
End Try
End Sub
When the code reaches the Page_Init all the variables are already set to nothing, and only happens. The weird part is that there are more things you can do that uses that MasterPage but just fails when doing this one.
Thank you.
Iker