Click here to Skip to main content
16,008,175 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Binary Data Pin
Imran Khan Pathan25-Oct-07 18:42
Imran Khan Pathan25-Oct-07 18:42 
GeneralRe: Binary Data Pin
N a v a n e e t h25-Oct-07 19:41
N a v a n e e t h25-Oct-07 19:41 
QuestionServer Side Alert Messages. Pin
Dio2225-Oct-07 10:23
Dio2225-Oct-07 10:23 
AnswerRe: Server Side Alert Messages. Pin
Malcolm Smart25-Oct-07 10:27
Malcolm Smart25-Oct-07 10:27 
AnswerServer Side Alert Messages. Pin
Sarani Ravindran28-Oct-07 1:12
Sarani Ravindran28-Oct-07 1:12 
Questionrandomly changing images with a time interval Pin
sivaram praveen25-Oct-07 7:58
sivaram praveen25-Oct-07 7:58 
AnswerRe: randomly changing images with a time interval Pin
pmarfleet25-Oct-07 10:04
pmarfleet25-Oct-07 10:04 
Questionlogout not abandoning session Pin
janetb9925-Oct-07 7:05
janetb9925-Oct-07 7:05 
I've got a custom asp.net 2 login authentication creating a generic principal object and working great except that I can't get the logout to truly abandon/clear. For most of the site, I'm using one master page, but for the secure area, I'm using another master page. The secure master page uses menus, with the logout being a menu item redirect to another page (login.aspx?id=logout) with request parameters to fire. When I click logout, it does indeed take me back to the login page. But, if I manually type in the page where I've just been, it lets me through without a login. I've tried researching the problem and implementing suggestions to others, but nothing has worked. Any help GREATLY appreciated.

webConfig:
<authorization><allow users="*">
<trust level="Full" originurl=""><authentication mode="Forms">
<forms loginurl="calendar/login.aspx" protection="All" timeout="60" name=".myCookie" path="calendar/" requiressl="false" slidingexpiration="true" defaulturl="calendar/default.aspx" cookieless="UseDeviceProfile" enablecrossappredirects="false">


global.asax
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
If HttpContext.Current.User IsNot Nothing Then
If HttpContext.Current.User.Identity.IsAuthenticated Then
If TypeOf HttpContext.Current.User.Identity Is FormsIdentity Then
' Get Forms Identity From Current User
Dim id As FormsIdentity = DirectCast(HttpContext.Current.User.Identity, FormsIdentity)
' Get Forms Ticket From Identity object
Dim ticket As FormsAuthenticationTicket = id.Ticket
' userdata string was retrieved from stored user-data
Dim userData As String = ticket.UserData
Dim roles As String() = userData.Split(","c)
' Create a new Generic Principal Instance and assign to Current User
System.Web.HttpContext.Current.User = New System.Security.Principal.GenericPrincipal(id, roles)
End If
End If
Else
System.Web.HttpContext.Current.User = Nothing
End If
End Sub

login.aspx
Function myAuth(ByVal mySql As String) As Boolean
'Response.Write(mySql)
FormsAuthentication.Initialize() ' Initialize FormsAuthentication
' Create connection and command objects , contactRole
Dim strConn As String = ConfigurationManager.ConnectionStrings("strConn").ConnectionString
Dim cn As New Data.SqlClient.SqlConnection(strConn)
Dim cmd As Data.SqlClient.SqlCommand
cmd = New Data.SqlClient.SqlCommand(mySql, cn)
cmd.Connection.Open()
Dim reader As Data.SqlClient.SqlDataReader = cmd.ExecuteReader()
Dim returnUrl As String, myReset As Boolean = False
If reader.Read() Then
Dim ticket As New FormsAuthenticationTicket(1, reader(0).ToString, DateTime.Now, DateTime.Now.AddMinutes(30), False, reader.GetString(1), FormsAuthentication.FormsCookiePath)
Dim hash As String = FormsAuthentication.Encrypt(ticket)
Dim cookie As New HttpCookie(FormsAuthentication.FormsCookieName, hash)
cookie.Expires = ticket.Expiration
Response.Cookies.Add(cookie)
lblPid.Text = reader(0).ToString
System.Web.HttpContext.Current.Session("UserNbr") = reader(0).ToString
returnUrl = Request.QueryString("ReturnUrl")
myReset = reader(2)
If myReset = True Then returnUrl = "~/secure/myAccount.aspx?upd=3&em=" & lblPid.Text
If returnUrl Is Nothing Then
returnUrl = "/calendar/secure/myAccount.aspx"
End If
' Don't call the FormsAuthentication.RedirectFromLoginPage here, it could replace the custom authentication
Response.Redirect(returnUrl)
Else
lblPid.Text = "0"
System.Web.HttpContext.Current.Session("UserNbr") = "0"
Response.Cookies.Clear()
System.Web.Security.FormsAuthentication.SignOut()
Session.Abandon()
Session.Clear()
End If
reader.Close()
cn.Close()
cmd.Dispose()
End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
If Not Page.IsPostBack Then
If Request("id") = "logout" Then
lblPid.Text = "0"
System.Web.HttpContext.Current.Session("UserNbr") = "0"
Response.Cookies.Clear()
Response.Clear()
System.Web.Security.FormsAuthentication.SignOut()
Session.Abandon()
Session.Clear()
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.Now)
txtUsername.Focus()
Else
If System.Web.HttpContext.Current.User Is Nothing Then
System.Web.HttpContext.Current.Session("UserNbr") = "0"
Response.Cookies.Clear()
Response.Clear()
System.Web.Security.FormsAuthentication.SignOut()
Session.Abandon()
Session.Clear()
txtUsername.Focus()
Else
Dim returnUrl As String = String.Empty
returnUrl = Request.QueryString("ReturnUrl")
If returnUrl Is Nothing Then
returnUrl = "~/calendar/secure/myAccount.aspx"
End If
End If
End If
End If
End Sub

secure master page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.Now)
End Sub

individual secure area page:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.Now)
End Sub
QuestionRegular expression for names Pin
kjosh25-Oct-07 5:48
kjosh25-Oct-07 5:48 
AnswerRe: Regular expression for names Pin
Expert Coming25-Oct-07 6:36
Expert Coming25-Oct-07 6:36 
AnswerRegular expression for names Pin
Sarani Ravindran28-Oct-07 1:42
Sarani Ravindran28-Oct-07 1:42 
QuestionConnecting To dialog box question.... Pin
David Knechtges25-Oct-07 5:35
David Knechtges25-Oct-07 5:35 
QuestionNested Master Page - Issues(Please help) Pin
Md Arif25-Oct-07 5:27
Md Arif25-Oct-07 5:27 
AnswerRe: Nested Master Page - Issues(Please help) Pin
Guffa25-Oct-07 6:02
Guffa25-Oct-07 6:02 
GeneralRe: Nested Master Page - Issues(Please help) Pin
Md Arif25-Oct-07 8:17
Md Arif25-Oct-07 8:17 
GeneralRe: Nested Master Page - Issues(Please help) Pin
Guffa25-Oct-07 10:25
Guffa25-Oct-07 10:25 
QuestionCould anyone know how to use AT Command via GSM modem?Thanks [modified] Pin
jaski25-Oct-07 5:02
jaski25-Oct-07 5:02 
AnswerRe: Could anyone know how to use AT Command via GSM modem?Thanks Pin
Saksida Bojan25-Oct-07 6:01
Saksida Bojan25-Oct-07 6:01 
Questiondisplaying text in lable Pin
jai 12325-Oct-07 4:05
jai 12325-Oct-07 4:05 
AnswerRe: displaying text in lable Pin
Pete O'Hanlon25-Oct-07 4:13
mvePete O'Hanlon25-Oct-07 4:13 
GeneralRe: displaying text in lable Pin
jai 12325-Oct-07 4:43
jai 12325-Oct-07 4:43 
GeneralRe: displaying text in lable Pin
Christian Graus25-Oct-07 11:14
protectorChristian Graus25-Oct-07 11:14 
QuestionDrag and Drop Between Listboxes Pin
cisco210325-Oct-07 4:05
cisco210325-Oct-07 4:05 
AnswerRe: Drag and Drop Between Listboxes Pin
Christian Graus25-Oct-07 11:16
protectorChristian Graus25-Oct-07 11:16 
Questiondisplay the count of records present in gridview in textbox Pin
Sunil Wise25-Oct-07 3:39
professionalSunil Wise25-Oct-07 3:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.