Help: Javascript for checking user

N

noor

hi,
can any one tell me a javascript that can be called on mouseover event of a
html link control .
script can check from session either a user is login or not
In the case of Login it will redirect to the given url.
In the case of not Login it will prompt the user that u r not login kindly
login.

actually that link leads a user to Download Software. but this feature is
only for registerd user.

kindly help me. it will be best if u give me a script for it.
Thanks
Noor
 
A

Ahmed Fouad

First of all JavaScript is not the correct way of implementing
authentication in ASP.NET applications. So you should consider something
which does not depend on the client browser to have JavaScript enabled so
that your authentication scripts can run properly. What happens to your
client-side authentication logic when someone has just disabled JavaScript
in his/her browser?

If you are using forms authentication (which will likely be the case), then
after successful login u need to store some kind of user identity in
SessionState so that you can tell whether the current request is
authenticated or not. Once you have that piece of identity stored in
SessionState its a matter of just one IF test against that identity to
ensure that your download page is only accessible to authenticated users.
Its a very basic and very common task in web-based applications. Try using
the FormsAuthenticationModule (ideally with SSL enabled) for this purpose.
This will make your application's authentication more robust. By using
FormsAuthenticationModule you don't need to manually check for whether the
request is authenticated or not. The module can be configured to
automatically enforce request authentication and resource protection without
writing a single line of code except checking against some kind of
credential store (Active Director, DBMS, etc). Try searching MSDN for "Forms
Authentication". You will certainly find some very nice articles written (by
example) for demonstrating FormsAuthentication in action.

Good Luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top