Click here to Skip to main content
11,715,160 members (64,242 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
Hi guys,

I want to prepared Login control, not use ASP.NET inbuilt Login view. I need your ideas to prepare this.

Idea 1: this method I know and work on fine, get username and password from user and fire select query in database, if database give record then user is authenticated and, user name store in session variable. If I try getting other page directly with URL then first I check the session variable. If it is not null then we load page, otherwise we redirect user to login page.

Now for this I need to check each and every page before loading and I think there some other way also but which I can’t get that.

Guys, please provide me your valuable suggestions not source code. Code I will manage.

Thanks in advance.
Posted 7-Apr-11 0:32am
Amit Kumar Tiwari at 7-Apr-11 6:54am
"suggestions not source code" 5+ for that :D
angle57 at 8-Apr-11 2:29am
Hi Amit Kumar Tiwari,
Thanks for this link, but this article suggest Java scripts, if user disable the java script this option not work, second there is some code we need to write more than one page also. So I will not use this option.
Please have you any other suggestion?
Or other masters have any good suggestion?
M. Sreekanth at 13-Sep-14 8:35am
All you need to do is create a Base class and inherit it in all your pages. Write your validation code once. That's it.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Here is an article just for you[^]

Hope that helps. Good luck.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

ASP.NET authentication and authorization[^]

Authorization MSDN[^]
MSDN Forms Authentication[^]
One of the best ones is:-
Cookieless ASP.NET forms authentication[^]
These are few very good links for providing authorization to everypage.
If you are using MVC, you can take use of the Authorization Attribute making a custom one. That would surely work out.

Hope these helps you anyway.
Rate this: bad
Please Sign up or sign in to vote.

Solution 7

First off I'd suggest using Membership or Identity as you'll get all this out of the box. But if this is for learning then add a global.asax file to the solution and use the BeginRequest event to check if the user has logged in

<%@ Application Language="C#" %>
<script runat="server">
void Application_BeginRequest(object sender, EventArgs e)
   if (string.IsNullOrWhiteSpace(Session["Username"])
Blutfaust at 21-Mar-15 12:40pm
Nice, but four years late.
F-ES Sitecore at 21-Mar-15 13:43pm
Good advice is worth waiting for
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Use Master page concept in your application. once you write the code for checking session variable in master page then its easy to work
Nelek at 15-Feb-14 7:55am
Almost 3 years late :P
Rate this: bad
Please Sign up or sign in to vote.

Solution 5

Hareesh's answer is correct. Use master page concept and derive every of those pages with it on which you want to check User validation.
Write Login/Session check code in Page_Init event of master page. Now it's a very basic concept that before loading a child page, master page Page_Init will call. So your problem is solved.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 495
1 Richard MacCutchan 275
2 Maciej Los 259
3 ManasKumarM 155
4 Frankie-C 125
0 Sergey Alexandrovich Kryukov 775
1 CHill60 415
2 Richard MacCutchan 405
3 Maciej Los 389
4 OriginalGriff 320

Advertise | Privacy | Mobile
Web03 | 2.8.150901.1 | Last Updated 21 Mar 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100