A user control to authenticate users

Hi all

I have a simple user control..with two textboxes(Email and Password) and a button and two links (Forgot your password & To  register click here) ... i'm using windows forms ... when the sign in button is clicked ...i'm trying to validate user credentials against a database..if valid..i instantiate a new principal object ...and place it in the Context.User

 

string encPassword = new User().Encrypt(txtPassword.Text);

MySitePrincipal newUser = MySitePrincipal.ValidateLogin( txtEmailAddress.Text, encPassword);

if (newUser != null)

{

Context.User = newUser;

Response.Redirect(Request.Path);

}

 

then..i'm calling Response.Redirect(Request.Path) to fire the page_load event of the control again to perform some customization

 

private void Page_Load(object sender, System.EventArgs e)

{

if(!IsPostBack)

{

MySitePrincipal currentUser = null;

if(Context.User is MySitePrincipal)

currentUser = (MySitePrincipal) Context.User;

if(currentUser != null)

{

///////////////////////////////

///Not signed in controls/////

//////////////////////////////

lblToRegister.Visible = false;

imgSignIn.Visible = false;

lnkPassword.Visible = false;

lnkRegister.Visible = false;

txtEmailAddress.Visible = false;

txtPassword.Visible = false;

REVEmail.Enabled = false;

REVPassword.Enabled = false;

lblEmail.Visible = false;

lblPassword.Visible = false;

btnSignIn.Visible = false;

 

/////////////////////////////

///Signed in controls////////

/////////////////////////////

imgWelcome.Visible = true;

btnSignOut.Visible = true;

btnProfile.Visible = true;

lblWelcomeMsg.Visible = true;

}

else

{

///////////////////////////////

///Not signed in controls/////

//////////////////////////////

lblToRegister.Visible = true;

imgSignIn.Visible = true;

lnkPassword.Visible = true;

lnkRegister.Visible = true;

txtEmailAddress.Visible = true;

txtPassword.Visible = true;

REVEmail.Enabled = true;

REVPassword.Enabled = true;

lblEmail.Visible = true;

lblPassword.Visible = true;

btnSignIn.Visible = true;

 

/////////////////////////////

///Signed in controls////////

/////////////////////////////

imgWelcome.Visible = false;

btnSignOut.Visible = false;

btnProfile.Visible = false;

lblWelcomeMsg.Visible = false;

}

}

}

 

 

The problem is that the Context.User is always a GenericPrincipal...although i  replaced it with my own MySitePrincipal after authenticating user...how could i solve this problem??

Thanks in advance

0
MxMxM
5/6/2005 9:29:12 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

0 Replies
894 Views

Similar Articles

[PageSpeed] 58
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Persisting data in a web user control, which contains a list of other web user controls.
 Hi All, I have a control I've created, which can have a number of child controls - also user controls - stored as an ArrayList, which can be added wither a design time or programmatically.My problem is when I add to the list programmatically, it doesn't persist them. So if I add 3 child controls in step 1 of a wizard, with the aim that those three will be visible inside the parent in step 3, what happens is that the parent has no child controls and the item count is 0.Can anyone help? Thanks in advance.Code:Parent Control Markup: <%@ Control Language="C#" Auto...

Web user control inside update panel replace with another web user control
 Hi there. I have a page with a menu. an and then the content. My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control. In normal language. Is there a way that i can load one web user control into antoher and then disposose the original? Thanks in advance hello. well, what ...

Login Control logs user in, but User is not authenticated, but user really is!
I am using aspnetmembershipprovider.  Everything works fine.  I slap a login control on my login page and am able to login and get to my secure folder etc.  When I try and put some code in the LoggedIn method "User.Identity.IsAuthenticated" = false, yet if I blow through that, I am logged, authenicated etc.  The documentation says that the LoggedIn event is "after the user is authenticated".  Any Ideas what is up?Thanks,TPS------------------------------------------------------Note Collaboration for your next confernce call.http://www.ConferenceCallNotes.com I am...

Add user control from user control to web page
Hi there, I have a user control, that is inside another user control on a web page. From this user contfol, I need to add something to a place holder on the parent web page. I am having troubles referencing the placeholder correclty. I can get it fine as build time, but on runtime it kicks up the "Object reference not set to an instance of an object" error. Any ideas would be greatly appreciated. -------------------------------------------------------------- protected Civil_and_Corporate.candcadmin._default _default; ------------------------- Control objControl...

Single page with multiple user web controls VS Multiple page with specific user web controls
I have a question regarding single page with multiple user web controls vs multiple page with specific user web controls   Option 1: I am of the opinion to have multiple pages with specific user web controls and use an object to store all the information as the user navigates through the application. And finally at the end, read this object and save all the information to the backend database.   Option 2: My respected team member suggests that we have only one page, with all the specific user web controls and not use an object, instead show/hide the user web controls based ...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

I have a web user control being used by another web user control, but the one being used will not display the labels in the resx file.
I am using DotNetNuke version 3.13 (might be 3.013) on a Window's XP machine, SP2. I have what I find to be an extremely odd situation. I have a project called TDS.Controls. This project is a web control library. Each control has its own resx file, which is located in the App_LocalResources directory. Each control inherits from Framework.UserControlBase, just like DotNetNuke's User control in DNN\Controls\User.ascx.vb. As a matter of fact, this control is doing the exact same thing I am trying to do. It is a web user control with its own resx file being used by another web user control (See ...

User Control Within UserControl
If I have a user control A and then inside it a user control B embedded/referenced within it.  User Control A has a panel defined (cpeNewUser) that I want to manipulate from the code behind of User Control B based on some event that happens.So putting this in my code behind of User Control B won't work as it has no idea of cpeNewUser:cpeNewUser.Collapsed = true;So is it because only at runtime they are married up and because of this you cannot access each other's objects at compile time?  How would I get this to work becuase I'm using all user controls inside a AJAX Too...

User Control in a User Control
I have a first user control that contain a second user control. If I cahe the first user control can I still dynamically control the second one or it is cached with the first one therefore can not control it anymore? Thanks When your first control is cached, its rendered out and its output is stored in the cache. On every request to the page containing your control that can satisfy it from cache, the output will just simply be inserted - your first control will never be instantiated or run in that case, so the second one wont be either. Hope this helps,Mike VolodarskyProgram Manager...

User control in a user control
Hello all, I have created a user control with some checkboxes, and public properties to get the values of these checkboxes. I have also created a second user control using the first user control; this second control also access the public properties of the first one. My problem is when I implement the second control in an aspx page, if I click at runtime the checkboxes in the first control, I am able to access its public properties from the methods of the second control but the values of these properties are wrong. while at design time, I do not have this problem. Than...

Web resources about - A user control to authenticate users - asp.net.web-forms

HID Global and Botosoft Launch Mobile Student ID System in West Africa to Authenticate Over 2 Million ...
CSO Australia - News, Industry Blogs, Tools and Resources for Data Security Executives

NAB uses voice recognition to authenticate banking customers
National Australia Bank (NAB) has deployed biometrics technology to allow customers to access their bank accounts using their voice.

Intel Launches Skylake vPro With Intel Authenticate
... engineering and more complex attack vectors can render passwords the easiest way to get into a company’s data. Intel is launching Intel Authenticate ...

Cable providers still leery of Apple TV, some refuse to authenticate 'HBO Go' app
In an interview on Thursday, HBO's CTO Otto Berkes outlined the troubles in bringing a totally in-house app to the Apple TV, but the bigger challenge ...

Eureka! Sports site authenticates users sans the password hassle
We've all been there at some point—tempted to create a user account on a website that's mildly interesting, but the hassle of creating yet another ...

Cisco Selects Netformx Discovery to Power New Net Authenticate Assessment Service
Cisco Selects Netformx Discovery to Power New Net Authenticate Assessment Service Business Wire (press release) SAN JOSE, Calif.(BUSINESS WIRE)Netformx®, ...

Google makes it easier to authenticate e-mail
... e-mail with just a few clicks in a control panel. Google announced today that it is making it easy for organizations using Google Apps to authenticate ...

CNN.com - CBS' experts say they didn't authenticate Bush memos - Sep 15, 2004
... memos alleging President Bush received special treatment during his service in the Texas Air National Guard told CNN Tuesday they did not authenticate ...

Insert Coin: PIPA Touch fingerprint reader lets phone owners authenticate most anything
In Insert Coin, we look at an exciting new tech project that requires funding before it can hit production. If you'd like to pitch a project, ...

Berkeley researchers authenticate your identity with just your brainwaves, replace passwords with passthoughts ...
In the future, instead of trying to type your mixed-case, numbers-and-punctuation on a painfully small smartphone screen, logging in might be ...

Resources last updated: 1/21/2016 5:40:15 AM