Hi
I'm building a site that has publicly available pages and password
protected pages. Publicly available pages reside in:
/public
and password protected pages reside in:
/private
I'm using FormsAuthentication to protect the pages in /private. I've
created a login page (login.aspx) which resides in /public. When trying
to access a page in /private, the browser is referred back to
/public/login.aspx, where the user is authenticated and sent back to
the referring page in /private. Great, it all works....BUT... when a
user goes directly to /public/login.aspx and authenticates, they are
referred to /public/Default.aspx. Dang! Well, fair enough, I'm using:
FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, False)
and if there is no referring URL then it has to use a default.
What I want to happen, is when there is no referring URL, the user
should be forwarded to say, /private/profile.aspx.
Does anyone know a way of overriding the default?
Thanks in advance. 3 3594
Hi Phil,
This is the way that forms authentication works unfortunately.
One way to get around it is if there is no ReturnUrl passed in the
query string to the login page to have a default.aspx and redirect from that
page to
/private/profile.aspx.
I do not know of any other way of overriding this behaviour in forms
authentication.
Regards,
Stuart A Hill
MCSD, MCT
"Phil Certain" <c9******@fastmail.co.uk> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com... Hi
I'm building a site that has publicly available pages and password protected pages. Publicly available pages reside in:
/public
and password protected pages reside in:
/private
I'm using FormsAuthentication to protect the pages in /private. I've created a login page (login.aspx) which resides in /public. When trying to access a page in /private, the browser is referred back to /public/login.aspx, where the user is authenticated and sent back to the referring page in /private. Great, it all works....BUT... when a user goes directly to /public/login.aspx and authenticates, they are referred to /public/Default.aspx. Dang! Well, fair enough, I'm using:
FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, False)
and if there is no referring URL then it has to use a default.
What I want to happen, is when there is no referring URL, the user should be forwarded to say, /private/profile.aspx. Does anyone know a way of overriding the default?
Thanks in advance.
You will have to work around this problem as "default.aspx" is hardcoded
into the GetRedirectUrl method.
Here is some pseudo code for this RedirectFromLoginPaeg method method
RedirectFromLoginPage(...)
{
FormsAuthentication.SetAuthCookie(...)
Response.Redirect( FormsAuthentication.GetRedirectUrl( ... ) )
}
btnLogin_Click(..)
FormsAuthentication.SetAuthCookie();
string url = Request.Querystring["ReturnUrl"];
if ( url == null )
Response.Redirect( "/private/profile.aspx", true );
else
Response.Redirect( url, true );
bill
"Phil Certain" <c9******@fastmail.co.uk> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com... Hi
I'm building a site that has publicly available pages and password protected pages. Publicly available pages reside in:
/public
and password protected pages reside in:
/private
I'm using FormsAuthentication to protect the pages in /private. I've created a login page (login.aspx) which resides in /public. When trying to access a page in /private, the browser is referred back to /public/login.aspx, where the user is authenticated and sent back to the referring page in /private. Great, it all works....BUT... when a user goes directly to /public/login.aspx and authenticates, they are referred to /public/Default.aspx. Dang! Well, fair enough, I'm using:
FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, False)
and if there is no referring URL then it has to use a default.
What I want to happen, is when there is no referring URL, the user should be forwarded to say, /private/profile.aspx. Does anyone know a way of overriding the default?
Thanks in advance.
Hi William,
Many thanks for this - it works exactly as required.
Phil
William F. Robertson, Jr. wrote: You will have to work around this problem as "default.aspx" is
hardcoded into the GetRedirectUrl method.
Here is some pseudo code for this RedirectFromLoginPaeg method method RedirectFromLoginPage(...) { FormsAuthentication.SetAuthCookie(...) Response.Redirect( FormsAuthentication.GetRedirectUrl( ... ) ) }
btnLogin_Click(..)
FormsAuthentication.SetAuthCookie(); string url = Request.Querystring["ReturnUrl"]; if ( url == null ) Response.Redirect( "/private/profile.aspx", true ); else Response.Redirect( url, true );
bill
"Phil Certain" <c9******@fastmail.co.uk> wrote in message news:11*********************@f14g2000cwb.googlegro ups.com... Hi
I'm building a site that has publicly available pages and password protected pages. Publicly available pages reside in:
/public
and password protected pages reside in:
/private
I'm using FormsAuthentication to protect the pages in /private.
I've created a login page (login.aspx) which resides in /public. When
trying to access a page in /private, the browser is referred back to /public/login.aspx, where the user is authenticated and sent back
to the referring page in /private. Great, it all works....BUT... when
a user goes directly to /public/login.aspx and authenticates, they
are referred to /public/Default.aspx. Dang! Well, fair enough, I'm
using: FormsAuthentication.RedirectFromLoginPage(txtUsern ame.Text, False)
and if there is no referring URL then it has to use a default.
What I want to happen, is when there is no referring URL, the user should be forwarded to say, /private/profile.aspx. Does anyone know a way of overriding the default?
Thanks in advance. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike |
last post by:
I want to exempt an entire subdirectory "/help" from the need for
FormsAuthentication. How can I do it?
I am using .Net FormsAuthentication to require login to all non member pages
in my...
|
by: VR |
last post by:
Hi,
I am using Forms type of authentication, but having
problems redirecting users to default page after they get
authenticated.
My default page is default.aspx, but it's in 'public'...
|
by: T. Regan |
last post by:
I have a test app where I have Forms Authentication set up.
When I build and run the app as http://localhost/testapp/login.aspx, it runs
correctly. I get the login prompt and the proper...
|
by: Ed West |
last post by:
Hello
This SignOut code is not working, people are still logged in after it
redirects to default.aspx. any ideas? Thanks.
public class logout : System.Web.UI.Page {
private void...
|
by: tshad |
last post by:
I have a logon page that is may be called by the Forms Authentication setup.
This would put a ReturnURL as part of the URL. I would normally then just
issue a:
...
| |
by: Alex Nitulescu |
last post by:
Hi. I have two questions, please:
a) If I go DIRECTLY to Login, there's no Request.Params("ReturnURL"), and
therefore RedirectFromLogin won't work, because it will try to go to a page
named...
|
by: Jeremy Chapman |
last post by:
I have built a web app. While testing I have found that if I browse to a
page in the app, then get redirected to the login page and enter my
credentials. The...
|
by: Åženol Akbulak |
last post by:
Hello;
I use in my web application FormsAuthentication. Also I use Session state
(InProc).
When a user logged in, I can read Session parameters. (For example
Session). Problem is that, when...
|
by: Keithb |
last post by:
I am using the login control on my web site, which has both authenticated an
unauthenticated users. I added a logout page that is supposed to allow an
authenticated user to drop his authentication...
|
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,...
|
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...
| |
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...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |