| Author |
|
prg74 New User

Joined: November/06/2006 Location: United States
Online Status: Offline Info: 5
|
| Added: November/06/2006 at 1:59pm | IP Logged
|
|
|
Is it possible to access the session values - HttpContext.Current.Session("Username") - on pages that are not protected?
I want to display a link to the protected area from an unprotected area if a user is logged in...
|
| Back to Top |
|
| |
cwilliams Admin Group

CJWSoft Web Software Developer
Joined: April/06/2004
Online Status: Offline Info: 1769
|
| Added: November/06/2006 at 3:10pm | IP Logged
|
|
|
you can do that
1.) if the user is logged in 2.) if the page extension is ".aspx" 3.) if the page in question is part of the same application in IIS
you can not do it otherwise so if a page is ".htm" it must be renamed to ".aspx"
__________________
Best Regards,
Christopher Williams
www.CJWSoft.com
|
| Back to Top |
|
| |
prg74 New User

Joined: November/06/2006 Location: United States
Online Status: Offline Info: 5
|
| Added: November/06/2006 at 3:25pm | IP Logged
|
|
|
I seem to be suffering from the same as a previous post regarding code-behind pages and having to refresh to get things to work.
Should I take this as an idication that I should abandon using code behind files for these tasks relating to the logged in user?
|
| Back to Top |
|
| |
cwilliams Admin Group

CJWSoft Web Software Developer
Joined: April/06/2004
Online Status: Offline Info: 1769
|
| Added: November/06/2006 at 4:00pm | IP Logged
|
|
|
Perhaps but not necessarily..
As far as I know the person did not try this suggestion I gave them and I have a feeling that will probably work..
Try just putting a function in your code behind and grabbing it when you need it instead of the page load deal..
That person just gave up and decided grabbing it (non code behind) would work for them.
Using Page Load is the real issue error..
If trying something like that does not work out for you you'll have to make due with the works for now.. Still if your going to a non protected ".aspx" after login to the site I dont totally see how that could be related to what this guy is talking about ? If you need a page refresh there thats weird cause login already happened somewhere else?
__________________
Best Regards,
Christopher Williams
www.CJWSoft.com
|
| Back to Top |
|
| |
prg74 New User

Joined: November/06/2006 Location: United States
Online Status: Offline Info: 5
|
| Added: November/06/2006 at 4:32pm | IP Logged
|
|
|
Well my scenario is different yet similar.
I have a GlobalClass file located in App_Code.
It contains a function:
Public Shared Function GetSessionItem(ByVal sSessionItem As String) As String Return HttpContext.Current.Session(sSessionItem) End Function
This is to return the value of a given session var.
Then I also have a Sub in the GlobalClass that is called upon page load from my aspx.vb code behine file. This Sub finds a control(s) on a page (in this case a DIV with runat="server") and executes code for that control. In this instance it is going to build the innerHTML of the menu div.
-------------------- Dim oCtl As HtmlGenericControl = CType(FindControlRecursively("topnav", oControlsCollection), HtmlGenericControl) If Not IsNothing(oCtl) Then Dim sCompanyNav As New StringBuilder() sCompanyNav.Append("<ul>" & vbNewLine) sCompanyNav.Append("<li><a href=""" & GetServerUrl() & "about/"" title=""About BNK"">About</a></li>" & vbNewLine) sCompanyNav.Append("<li><a href=""" & GetServerUrl() & "events/"" title=""Events"">Events</a></li>" & vbNewLine) sCompanyNav.Append("<li><a href=""" & GetServerUrl() & "contact/"" title=""Contact Us"">Contact</a></li>" & vbNewLine) If GetSessionItem("Username") <> "" Then sCompanyNav.Append("<li><a href=""" & GetSecureServerUrl() & """ title=""MyBNK"">MyBNK</a></li>" & vbNewLine) sCompanyNav.Append("<li><strong><a href=""" & GetSecureServerUrl() & "users/logoff.aspx"" title=""Logoff"">Logoff</a></strong></li&g t;" & vbNewLine) Else sCompanyNav.Append("<li><a href=""" & GetSecureServerUrl() & "users/aspplogin.aspx?ReturnUrl=" & GetServerUrl & "members/"" title=""Client Login"">Client Login</a></li>" & vbNewLine) End If sCompanyNav.Append("</ul>" & vbNewLine) oCtl.InnerHtml = sCompanyNav.ToString End If -------------------------------------------
There are 2 sections to the site... the protected & the non-protected.
The code above is to generate the menu on non-protected pages so that should someone be logged in they can quickly click a link and be in their protected section.
When go to default.aspx (the home page) I get the login link since I am not logged in. I click it. I am taken to the login form and I login successfully. I am redirected and it is as if I never logged in. I go to a protected page, then back to the home page...
It shows me as logged in.
I am also having the issue where upon logging in and going to a protected you must refresh the page in order to access the session vars from a code behind page. Which is certainly due to calling a sub or function from the Page_Load event.
|
| Back to Top |
|
| |
cwilliams Admin Group

CJWSoft Web Software Developer
Joined: April/06/2004
Online Status: Offline Info: 1769
|
| Added: November/06/2006 at 5:17pm | IP Logged
|
|
|
OK, THIS PART
When go to default.aspx (the home page) I get the login link since I am not logged in. I click it. I am taken to the login form and I login successfully. I am redirected and it is as if I never logged in. ?????????? I go to a protected page, then back to the home page...
Please explain that in as much detail as possible because I just don't totally understand what you are saying. Your talking about a login link but your not telling me what it is exactly and where its going.. your talking about being redirected.. etc etc etc I just don't totally get what your saying as I can get mutiple scenarios out of all of that..
__________________
Best Regards,
Christopher Williams
www.CJWSoft.com
|
| Back to Top |
|
| |
cwilliams Admin Group

CJWSoft Web Software Developer
Joined: April/06/2004
Online Status: Offline Info: 1769
|
| Added: November/06/2006 at 9:05pm | IP Logged
|
|
|
also, which session variables are involved
__________________
Best Regards,
Christopher Williams
www.CJWSoft.com
|
| Back to Top |
|
| |
prg74 New User

Joined: November/06/2006 Location: United States
Online Status: Offline Info: 5
|
| Added: November/07/2006 at 10:13am | IP Logged
|
|
|
My apologies for being unclear.
As it pertains to -- I am redirected and it is as if I never logged in. ??????????
Visualuize a link on the home page that says "Member Login" clicking that link takes you to http://localhost/memebers/aspplogin.aspx?ReturnUrl=http://lo calhost/members/
So you enter your login information and submit.
You successfully authenticate and are redirected to the ReturnUrl.. All is well.
Well upon arrival to the members home page the code referenced above does not seem to work until the page is manually refreshed.
I want to display session information along with some database information specific to the logged in user.
For my GetSessionItem function referenced above I have set it up so that I can get any session variable I want and I will use most all of them.
So that covers the manual refresh issue I have with a protected page.
Now the other thing I am seeing... is if I login and then go directly to an unprotected page I am unable to access any session variables until I visit a protected page first, and only then after I do a manual refresh of the protected page.
Hopefully that makes sense.
I am begining to see that I am going to have to modify what I am doing greatly in order to work with this add-in... whereas with ASPProtect Full Version 7.x things are much easier to accomplish.
|
| Back to Top |
|
| |
cwilliams Admin Group

CJWSoft Web Software Developer
Joined: April/06/2004
Online Status: Offline Info: 1769
|
| Added: November/07/2006 at 11:52am | IP Logged
|
|
|
Well, ASP.NET is and always will be a pain in da ass. Classic ASP will always be simpler, easier to deal with, and more or less work the way you expect it to.
I'll try to do some more testing on this later this week when I get home from a trip I am on right now. Perhaps I can come up with some good ideas.
In the meantime try this.. make you function test to see if the session variable exisits.. if not redirect back to the same page.. which should get the values that time.. something clever like that..
__________________
Best Regards,
Christopher Williams
www.CJWSoft.com
|
| Back to Top |
|
| |