473,385 Members | 1,888 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,385 software developers and data experts.

asp:Login and registering user with Membership

I have a Server.Transfer in my asp:Login LoggedIn event handler. I am forcing
transfer to a specific page since I do not want to use the ReturnURL that is
in Request.Params (i.e., the user addressed some particular page and was
redirected to the login form and would be returned there.).

The control's DestinationUrl is only used if the login page was the original
target of the request.

In the event handler, HttpContext.Current.User.Identity.Name is empty. So,
when I go to the target of the Server.Transfer, Membership.GetUser() returns
null. Apparently, user information is not set into the sesssion until after
the request completes.

Unfortunately, I want to use Role information to configure the apps real
home page. I am using Membership and Roles throughout the app and would like
to be consistent here. Currently, no page gets any info about the user except
through Membership, and I'd like to not be passing the name around.

My guess is that Membership is carefully designed not to let you plug a name
into it.

Maybe the LoggedIn event should be renamed to the AlmostLoggedIn event.

Thx

Marc
Mar 22 '07 #1
3 3184
Hi Marc,

Regarding on the Login control(LoggedIn event) and membership service
behavior you mentioned, I think it is the expected one due to how the
FormsAuthentication issue authenticate ticket and retrieve it back at
sequential requests.

When the user click "login" button of the ASP.NET application login
page(secured through forms authentication), the following occurs:

1. Login control look for the membership provider and use it to verify the
username/password credentials

2. If validate success, it will generate authentication ticket and store it
into response's cookie collection

3. use response.Redirect to forward the user to the original requested
page(or the default page which can be configured in Formsauthentication
setting)
For your case, you use "Server.Transfer" to forward the user. Then, because
server.transfer does not return to client-side, so the
authentication-ticket(cookie) hasn't been able to store in client cookie,
and request also doesn't go through the Forms AuthenticationMOdule which
will populate the Context.User.Identity(from authentication ticket).
That's why you can not get the Context.User.Identity if you use
"Server.Transfer" after LoggedIn.

One way to overcome this problem is use Response.Redirect instead of
Server.Transfer. This make the a client-side redirection which can ensure
the authentication ticket(cookie) be persisted and updated, and the new
redirected request will got through the FormsAutheitcation Module that
help correctlyl populate the Context.User.Identity property. How do you
think?

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 23 '07 #2
Perfect Steven - Thank you.

I'd forgotten that I used the Server.Transfer as an "optimization" (as
recommended in many asp.net books) in order to avoid what appeared to be a
useless round trip. Apparently, it isn't useless after all.

Would have been nice if the docs on the LoggedIn event identified the issue.

Marc

Mar 23 '07 #3
Thanks for your reply Marc,

Yes, I agree that Server.Transfer will avoid client-side roundtrip and in
most cases(if it won't affect your application logic), you're recommended
to use Server.Transfer instead of Response.Redirect. The Login control here
should be a particular case :-).

Also, for the document, there does have some incompleteness in the current
MSDN product document, however, the MSDN web document now support adding
user community comments. You can add your comment on this in the following
document page(in the bottom):

#Login.LoggedIn Event
http://msdn2.microsoft.com/en-us/lib...rols.login.log
gedin(VS.80).aspx

In addition, if you have any more specific feedback or requests, you're
welcome to post in our product feedback center:

http://connect.microsoft.com/feedbac...spx?SiteID=210

Thanks for your feedback!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 26 '07 #4

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

Similar topics

1
by: Wayne Smith | last post by:
Applies to: Microsoft FrontPage 2000, Microsoft Access 2000, IIS 5.0 Operating System: Microsoft Windows 2000 Professional I am trying to protect a portion of a web site by allowing users to...
1
by: David Brown | last post by:
In ASP.NET 2.0, I am using the asp:login control, but I want to reduce the validation on the password. I dont want the user to have to put in a special character or a number etc. Is it...
0
by: jeff | last post by:
I am using the asp:login control and want to change the login failure message if the user has become locked out. I want to tell them to call technical support to reset their password. Does anyone...
5
by: R.A.M. | last post by:
Hello Could you help a beginner with login implementation using asp:Login (.NET 2.0). I have in Web.config: <authentication mode="Forms"> <forms name="Demo.NET" loginUrl="Default.aspx" />...
2
by: Sasquatch | last post by:
I'm having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight forward,...
2
by: Sasquatch | last post by:
I'm still having trouble creating a simple login page using the asp:login control. I followed some instructions in a WROX book, "Beginning ASP.NET 2.0," and the instructions are very straight...
3
by: HeatherBMI | last post by:
I've been searching for a way to test this control with my NUnitASP tests for awhile now and have yet to come up with anything. I have all of my tests written, but until I can get past the initial...
3
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
The majority of pages on our site need authentication (forms auth against the aspnetdb database). I created an '~/auth' folder with its own config file forcing authentication for any pages in the...
2
by: zaifi | last post by:
I how to use asp login control with oracle databse..please explain me and source code.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.