473,396 Members | 2,024 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,396 software developers and data experts.

Passing parameters to login page with authentication forms

Hello NG,

i need to know how i can pass parameters to the loginpage if i use
authentication mode Forms. I need to pass different paramaters, such as
a different redirection url, strings and paths to graphics depending on
the page the user gets redirected to the loginpage. I found no way to
achieve this, since the redirection seems to happen in the background
automatically if i set authentication mode to forms.

Any ideas are appreciated.

Jens

Nov 19 '05 #1
7 2501
Hi,

Why not set a value in a session variable depending on the page being viewed
and then check the value in the login page? This seemed the easiest approach
for me.

I am not sure if there is any built-in mechanism in Asp.net for your
requirement.

++Vijay R
"Trollpower" wrote:
Hello NG,

i need to know how i can pass parameters to the loginpage if i use
authentication mode Forms. I need to pass different paramaters, such as
a different redirection url, strings and paths to graphics depending on
the page the user gets redirected to the loginpage. I found no way to
achieve this, since the redirection seems to happen in the background
automatically if i set authentication mode to forms.

Any ideas are appreciated.

Jens

Nov 19 '05 #2
Thank you Vijay for your response,

The problem here is, that the loginpage gets called without any code
from me. The only thing i had to do is activate Forms mode
authentication and the loginpage gets called as soon as the user tries
to access a ressource in the folder.

So i dont know where to set Sessionvariables, since no code is executed
in the target page. If you know where to put this code, so that it gets
executed before the login page gets called, I will appreciate that.

Thanks again for you spent time on my problem.

Jens
*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
Rolling you own security is not very hard. If FormsAuthentication
doesn't do everything you want, just rewrite the parts you need and
keep the rest.

In this case, I'd derive a class off of System.Web.UI.Page, and derive
your pages from that. Have YourPage sniff user context out of the
FormsAuthentication model, figure out if the user belongs where he's
trying to go, then manually kick him to the login page along with any
custom parameters you want. If you set ?url=whereYouCameFrom.aspx, you
won't even have to modify your login code.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #4

Yap Basically u need to write a class which derives from system.web.ui.page.
WRite ur code in one of the method...and check here if user is authenticated
or not...or write ur own logic to redirect user/customize URL....
Inherit all ur webforms from this class.But only disadvantage with this
method is that u'll not get the design view of the page as it is derived from
custom class...

"jasonkester" wrote:
Rolling you own security is not very hard. If FormsAuthentication
doesn't do everything you want, just rewrite the parts you need and
keep the rest.

In this case, I'd derive a class off of System.Web.UI.Page, and derive
your pages from that. Have YourPage sniff user context out of the
FormsAuthentication model, figure out if the user belongs where he's
trying to go, then manually kick him to the login page along with any
custom parameters you want. If you set ?url=whereYouCameFrom.aspx, you
won't even have to modify your login code.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #5
Thank you very much for your answers. They gave me an idea on how to
solve the problem. The Problem now is, that we need designer support
for the page, since we have to make a lot of these. So doeas anyone
knows how to make the derived classed supported by the designer?

Thanks in advance

Jens

Nov 19 '05 #6
I use derive all my pages from custom objects, and I've never had a
problem pulling them up in the designer. What specific problem are you
having?

Frankly, if you have developers relying on the designer, I'd recommend
changing this practice. That's the quickest way for junior devs to
churn out unmaintainable code. I always write all my HTML by hand, and
require the same of my team members.

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #7
Jens,
If you don't mind handling the security yourself, you can put a code
block at the top of each application page that checks for a session
variable (e.g. session("UserID") ). If it is <> "" then let them go on
with Page_Load, otherwise redirect to the login page where a successful
login will set that session variable. It's not the most elegant way to
do it, and I'm sure there are better ways to handle authentication, but
it works.

Nov 19 '05 #8

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

Similar topics

9
by: buran | last post by:
Dear ASP.NET Programmers, How can I post data to an ASP.NET login page and pass authentication? The login page uses forms authentication, users must supply usernames and password and have to...
7
by: Wade Wegner | last post by:
Hello, I have been desperately trying to programmatically authenticate a windows user, create their credentials, and then redirect them to a different server while passing the credentials at the...
11
by: David W. Simmonds | last post by:
I have a form that will prompt for a user name/password. In VS.NET, I have the protected form in a folder named Admin. I have a Web.config file in that folder as well. It contains the following...
4
by: nicholas | last post by:
Hi, Got an asp.net application and I use the "forms" authentication mode defined in the web.config file. Everything works fine. But now I would like to add a second, different login page for...
4
by: SB | last post by:
Hi I'm trying to get forms-based authentication to authenticate different users for differet pages, like this: <configuration> <location path="Member" allowOverride="true"> <system.web>...
9
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a...
7
by: Alan Silver | last post by:
Hello, Sorry this is a bit wordy, but it's a pretty simple question... I have a web site, http://domain/ which is a public site, part of which (http://domain/a/) is protected by forms...
7
by: Samuel Shulman | last post by:
Is there a method that will indicate the person who logged successfully is Logged and therefore allowed to browse freely other then using the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.