Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session State 1

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
With Classic ASP, the session state was easily implemented using session("someName") = "someValue".

With a current ASP.NET app I'm trying out, I want to restrict the user from a "member" area by verifying that they logged in appropriately. To do this, I want to activate a session flag variable as true at the login page, and if anyone tries to hit a page where they need authorization, but they do not have that session flag verifying that they logged in, it will kick them out.

When implementing the checking / verifying page, I entered the following code, and the .NET framework gave me a compilation error that says: BC30512: Option Strict On disallows implicit conversions from 'String' to 'Long'.

I'm not sure how it is being converted to a Long value. Does anyone else have any idea why this isn't working?

Code on flagChecker.aspx
Code:
<%
  If session("signupFlag") Is Not "True" Then
    Dim msg as String
    msg = "You do not have authorization to access this area."
    Response.Redirect("/noAccess.aspx?msg=" & Server.URLEncode(msg))
    Response.End
  End If
%>

-Ovatvvon :-Q
 
If session("signupFlag") Is Not "True" Then
should be
Code:
If Not session("signupFlag") = "True" Then

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
For some reason the equal sign wouldn't work...the page gave me an error and told me to use "Is" instead of "=". Know why we can't use = signs?

Anyway, you pointed me in the right direction, and it works now. Thanks! :p *star for you*


-Ovatvvon :-Q
 
You don't need to do this for ASP.NET. The standard "Forms Authentication" does it all automatically. Do a web search for ".NET Forms Authentication web.config" and you'll likely find everything you need.

In short: you create a login.aspx page. You configure web.config, telling it about this page.

Then, anyone who browses to any file in the folder that has the same scope as web.config, if not authenticated, are redirected to your login.aspx page.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
If that's the case, it sounds a lot easier and quicker. I'll check that out, and if I find out how, I'll post back with a star. Thanks for the direction.

-Ovatvvon :-Q
 
tgreer,

I made a new thread asking about the web.config file and site security. It is in thread: thread855-1070454

If you could take a look at it, I'd really appreciate it!!

:)


-Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top