473,396 Members | 1,975 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.

Authentication/Automatic Redirect?

Hi

Hope someone can help me with authentication and how the redirects work. I'
ve already tried searching previous posts but didn't really find anything.

for I have a page that checks to see if the user has logged in. If not, it
redirects them to the login page for authentication. After authenticating, I
want to redirect them back to the original page that sent them. I always get
redirected back to the default page. I noticed that the '?RedirectURL'
parameter is not being set so my question is how does this get set?

Here's me web.config code"
<authentication mode="Forms" >
<forms
name="fpSupport"
path="/"
loginUrl="Accounts/Login.aspx"
protection="All"
timeout="30">
</forms>
</authentication>
Here's the code that redirects them to the login page if they are not
authenticated:
If Not Context.User.Identity.IsAuthenticated Then
Response.Redirect("Accounts/Login.aspx")
End If
And here's the code on the login page after they have been authenticated:

FormsAuthentication.SetAuthCookie(UserName.Text, chkPersist.Checked)
FormsAuthentication.RedirectFromLoginPage(UserName .Text,
chkPersist.Checked)

Any assistance would greatly be appreciated!

- Donald

Nov 18 '05 #1
6 1919
"Donald Williamson" <do**@fpoint.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi

Hope someone can help me with authentication and how the redirects work. I' ve already tried searching previous posts but didn't really find anything.

for I have a page that checks to see if the user has logged in. If not, it redirects them to the login page for authentication. After authenticating, I want to redirect them back to the original page that sent them. I always get redirected back to the default page. I noticed that the '?RedirectURL'
parameter is not being set so my question is how does this get set?

Here's me web.config code"
<authentication mode="Forms" >
<forms
name="fpSupport"
path="/"
loginUrl="Accounts/Login.aspx"
protection="All"
timeout="30">
</forms>
</authentication>

If you're using Forms Authentication, your code should not be checking to
see if the user is authenticated. Instead, set up the <authorization>
section properly, and Forms Authentication will do it for you.
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #2
Thanks John,

One more question about the <authorization>. I am setting up many multiple
directories. I only want to give anonymous permission to a few select
files. Most others will require that they be authenticated to view the files
in most of the directories.

Do I create a separate <authorization> config file for each directory that
needs to be authenticated or what is the best way to do this? Thanks again
for any help.

- Donald


If you're using Forms Authentication, your code should not be checking to
see if the user is authenticated. Instead, set up the <authorization>
section properly, and Forms Authentication will do it for you.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #3
"Donald Williamson" <do**@fpoint.com> wrote in message
news:O4**************@tk2msftngp13.phx.gbl...
Thanks John,

One more question about the <authorization>. I am setting up many multiple directories. I only want to give anonymous permission to a few select
files. Most others will require that they be authenticated to view the files in most of the directories.

Do I create a separate <authorization> config file for each directory that
needs to be authenticated or what is the best way to do this? Thanks again
for any help.


You can put a separate web.config in each directory if you like. Mostly,
people use <location> elements to specify the configuration of the
subdirectories.
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #4
Thanks again John,

Getting closer ... hopefully my last question :) I'm working on the
location path. Here's what I have in my web.config:

<location path="~/Modules/SupportViewRequests/viewrequest.aspx">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>

This is placed before the main <system.web> settings where, in part, I have
the following:
<authentication mode="Forms" >
<forms
name="fpSupport"
path="/"
loginUrl="Accounts/Login.aspx"
protection="All"
timeout="30">
</forms>
</authentication>

I did remove the redirect in my main page. However, I'm never automatically
getting redirected to the log-in page. What am I missing?

- Donald

You can put a separate web.config in each directory if you like. Mostly,
people use <location> elements to specify the configuration of the
subdirectories.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #5
Got it! FYI here's the correct code to lock the directory:

<location path="Modules/SupportViewRequests">
<system.web>
<authorization>
<deny users="?" />
</authorization>
</system.web>
</location>

- Donald

"Donald Williamson" <do**@fpoint.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
Thanks again John,

Getting closer ... hopefully my last question :) I'm working on the
location path. Here's what I have in my web.config:

<location path="~/Modules/SupportViewRequests/viewrequest.aspx">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>

This is placed before the main <system.web> settings where, in part, I have the following:
<authentication mode="Forms" >
<forms
name="fpSupport"
path="/"
loginUrl="Accounts/Login.aspx"
protection="All"
timeout="30">
</forms>
</authentication>

I did remove the redirect in my main page. However, I'm never automatically getting redirected to the log-in page. What am I missing?

- Donald

Nov 18 '05 #6
"Donald Williamson" <do**@fpoint.com> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
Thanks again John,

Getting closer ... hopefully my last question :) I'm working on the
location path. Here's what I have in my web.config:

<location path="~/Modules/SupportViewRequests/viewrequest.aspx">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>

This is placed before the main <system.web> settings where, in part, I have the following:
<authentication mode="Forms" >
<forms
name="fpSupport"
path="/"
loginUrl="Accounts/Login.aspx"
protection="All"
timeout="30">
</forms>
</authentication>

I did remove the redirect in my main page. However, I'm never automatically getting redirected to the log-in page. What am I missing?


Where's your main <authorization> element?
--
John Saunders
John.Saunders at SurfControl.com
Nov 18 '05 #7

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

Similar topics

11
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get...
4
by: Dave | last post by:
Hi, Is there anyway to mimic forms authentication's loginUrl and RedirectFromLoginPage functionality using Windows authentication? We are developing intranet sites using basic authentication...
3
by: David Kleyman | last post by:
Hello I would like to find out if there is a way to SignOut() the user and redirect the browser back to login page after time out period expired I've added these settings to my web.config file...
3
by: Peter Row | last post by:
Hi, I better get the background stuff out the way first, so here goes: - Porting a VB6 webclass app to VB.NET using HttpHandlers and FormsAuthentication - When someone visits my site...
0
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET...
3
by: Stephanie Stowe | last post by:
I am new to ASP.NET having come from ASP classic background. I need to understand authentication. I have a server running IIS which contains an ASP.NET app. On IIS the app has both anonymous and...
3
by: sefe dery | last post by:
hi ng, i try to create a asp.net 1.0 website on windows server 2003(Servername: ServerX) with iis 6.0. PROBLEM: The user should login with his windows credentials in basic.aspx and...
1
by: cyrusthevirus2007 | last post by:
I'm having a lot of difficulty finding any info on this. Maybe there is different approach. I have a web application X that uses form authentication. I want to be able to automatically login...
8
by: jonmundsack | last post by:
I have an intranet site on my LAN which has "anonymous access" turned OFF, and "integrated Windows authentication" turned on. This allows me to access the "AUTH_USER" server variable, which I use...
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,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.