Does Forms Authentication works with User Controls?

  • Thread starter Thread starter Guest
  • Start date Start date
I'm not sure I follow your question. Are you asking if the login form can
be a user control? If so, then the answer is yes. The site I am working on
has the login form present in the right hand navigation on all of the
publicly accessible pages. In order to facilitate that, I turned the log in
form into a small control, and included it on those pages. I also created a
web form, which contained information about parts of the site only being
accessible for members of the site, with a link to the registration form,
and with the login box also in the right hand navigation. It is this page
that you set the loginUrl in the web.config file to (in the authentication
section)

Hope that helps, and if I didn't answer your question, provide me with a
little more info, and I'll see what I can do to help.

-PJ Pirrello
 
I have only one page in my app (default.aspx) like portal starter kit. i load at runtime the tabs and options of my app.
There are subdirectories in my app called Ficha01, Ficha02, etc, Everyone can see the content of Ficha01 (user controls .ascx), but i want only authenticated users see content of Ficha02 (it has only user controls .ascx)

I thought that asp.net verify if a user is authenticated before do this (LoadControl)

Private Sub Page_Load...
Dim cContenido As Contro
cContenido = LoadControl("Ficha02/evmantenimiento.ascx"
cellContenido.Controls.Add(cContenido

"Ficha02/evmantenimiento.ascx" is an example, the usercontrol to load is determined at runtime
Thank you
 
As far as I know, the security only applies to pages, not to controls. You
can programmatically control access though (still use forms to authenticate,
but check credentials programmatically)

just do something like:

If User.Identity.IsAuthenticated()
'Load and add control only authenticated users can see
Else
'Load unauthenticated control, or do whatever processing you want to do
for anonymous users
End If

You can get a little more robust by using roles as well, and showing
different controls to users in different roles. If you need something more
robust, there are a ton of very good articles out there on using role based
security with forms authentication. I can point you at one if this sounds
like something you would want.

-PJ Pirrello

Jose Flores said:
I have only one page in my app (default.aspx) like portal starter kit. i
load at runtime the tabs and options of my app.
There are subdirectories in my app called Ficha01, Ficha02, etc, Everyone
can see the content of Ficha01 (user controls .ascx), but i want only
authenticated users see content of Ficha02 (it has only user controls
..ascx).
 
Back
Top