473,408 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Logging in with ASP.NET

Hi

I have a single login for a website, so my C# code is simply:

if (textUserName.Text.ToLower() == "admin" &&
textPassword.Text.ToLower() == "password")
{
Session["LoggedIn"] = true;
Response.Redirect("MyHome.aspx", false);
}
else
{
pResponse.Attributes["class"] = "Error";
pResponse.InnerText = "Login Failed. Please try again.";
pResponse.Visible = true;
}

I'm not sure if this is the BEST way, though. I've seen there is so
much functionality in the System.Web.Security library, but for a
simple case like this, is it worthwhile?

I get an intermittent problem where (on localhost, so far) my session
seems to expire quite quickly. I'm not sure if this is because of the
way I'm logging in, or if it's because of re-compilations while
debugging, so if the method above looks like it will create problems,
please let me know!!

Thanks
Sean
Jun 27 '08 #1
1 892
<se**************@hotmail.comwrote in message
news:93**********************************@56g2000h sm.googlegroups.com...
Hi

I have a single login for a website, so my C# code is simply:

if (textUserName.Text.ToLower() == "admin" &&
textPassword.Text.ToLower() == "password")
{
Session["LoggedIn"] = true;
Response.Redirect("MyHome.aspx", false);
}
else
{
pResponse.Attributes["class"] = "Error";
pResponse.InnerText = "Login Failed. Please try again.";
pResponse.Visible = true;
}

I'm not sure if this is the BEST way, though. I've seen there is so
much functionality in the System.Web.Security library, but for a
simple case like this, is it worthwhile?

I get an intermittent problem where (on localhost, so far) my session
seems to expire quite quickly. I'm not sure if this is because of the
way I'm logging in, or if it's because of re-compilations while
debugging, so if the method above looks like it will create problems,
please let me know!!
The problem with what you are doing is that you would have put a check on
each page which checks to see if they are logged in or not and redirect them
to the login page if they arn't. You should really use Forms Authentication
which will take all the work out for you. Have a look at some articles like:

http://www.ondotnet.com/pub/a/dotnet...rmsauthp1.html
http://msdn.microsoft.com/en-us/library/aa480476.aspx
http://www.4guysfromrolla.com/webtech/110701-1.shtml

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Neil Benn | last post by:
Hello, I'm running a test and having issues with logging, if I call logging.shutdown() and then want to start the logging going again then I get a problem as if I call shutdown, I can't get the...
1
by: jjesso | last post by:
I am trying to add a new logging level. logging.config.fileConfig("bengineLog.cfg") logging.CLIENT = logging.INFO + 1 logging.addLevelName( logging.CLIENT, 'CLIENT' ) logging.root.setLevel( )...
2
by: Tor Erik Sønvisen | last post by:
Hi Have the following code: import logging logging.basicConfig(level = logging.DEBUG, format = ' %(message)s', filename = 'rfs.log', filemode = 'w')
6
by: pmatos | last post by:
Hi all, I am trying to create a simple but efficient C++ logging class. I know there are lots of them out there but I want something simple and efficient. The number one requirement is the...
6
by: Burkhard Schultheis | last post by:
As I wrote last week, we have a problem with a DB2 V8 on Linux. Here is what is in db2diag.log during online backup: Starting a full database backup. 2004-04-01-02.33.54.760164 ...
3
by: Karuppasamy | last post by:
Hi I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net . I installed everything as per the Instructions given in the 'Development Using the Logging Block'. ...
3
by: Chris Smith | last post by:
Hola, pythonisas: The documentation for the logging module is good, but a bit obscure. In particular, there seems to be a lot of action at a distance. The fact that getLogger() can actually be a...
0
by: robert | last post by:
As more and more python packages are starting to use the bloomy (Java-ish) 'logging' module in a mood of responsibility and as I am not overly happy with the current "thickener" style of usage, I...
3
by: Lowell Alleman | last post by:
Here is the situation: I wrote my own log handler class (derived from logging.Handler) and I want to be able to use it from a logging config file, that is, a config file loaded with the...
4
by: samwyse | last post by:
In the Python 2.5 Library Reference, section 14.5.3 (Logging to multiple destinations), an example is given of logging to both a file and the console. This is done by using logging.basicConfig()...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.