Please help i would want to use the code below for my application to automatically be redirecting on all my web pages so that if the session expires it will always redirect to the login.
An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code
Additional information: Session state is not available in this context.
Imports System.Web.Optimization
Public Class Global_asax
Inherits HttpApplication
Sub Application_Start(sender As Object, e As EventArgs)
' Fires when the application is started
RouteConfig.RegisterRoutes(RouteTable.Routes)
BundleConfig.RegisterBundles(BundleTable.Bundles)
' Code that runs when a new session is started
If Session("Username") IsNot Nothing Then
'Redirect to Welcome Page if Session is not null
Response.Redirect("MenuAcademics.aspx")
Else
'Redirect to Login Page if Session is null & Expires
Response.Redirect("Logindata.aspx")
End If
End Sub
End Class
error comes here
If Session("Username") IsNot Nothing Then