Passing parameters to login page with authentication forms

T

Trollpower

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
 
G

Guest

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
 
J

Jens Meyer

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
 
J

jasonkester

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/
 
G

Guest

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...
 
T

Trollpower

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
 
J

jasonkester

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/
 
J

John.Net

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.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top