473,387 Members | 3,781 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,387 software developers and data experts.

FormsAuthentication.RedirectFromLoginPage

Hi,

For some reason the login.aspx webpage redirects to itself after a
successful login and not to the url in the address bar. I have stepped
through this with debug and it behaves as it is supposed to. What am I
overlooking? Try it.

http://www.sutorius.com/psyche
click the Administration link
username = user1
password = user1
private void cmdLogin_ServerClick(object sender, System.EventArgs e)
{
if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Value,chkPersistCookie
..Checked);

else

lblMsg.Text = "Invalid Log in";

Nov 19 '05 #1
8 2516
It looks like you've forgotten to call SetAuthCookie.
Here's more info:
http://authors.aspalliance.com/aspxt...uthCookie.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Andy Sutorius" <an**@sutorius.com> wrote in message
news:%s*********************@twister.southeast.rr. com...
Hi,

For some reason the login.aspx webpage redirects to itself after a
successful login and not to the url in the address bar. I have stepped
through this with debug and it behaves as it is supposed to. What am I
overlooking? Try it.

http://www.sutorius.com/psyche
click the Administration link
username = user1
password = user1
private void cmdLogin_ServerClick(object sender, System.EventArgs e)
{
if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Value,chkPersistCookie
.Checked);

else

lblMsg.Text = "Invalid Log in";


Nov 19 '05 #2
Steve, doesn't the redirectfromloginpage call create the cookie for you?

Andy, I've also had this when my web.config is not set up correctly to deny
anonymous users and *allow* authenticated users.

Bill

"Steve C. Orr [MVP, MCSD]" wrote:
It looks like you've forgotten to call SetAuthCookie.
Here's more info:
http://authors.aspalliance.com/aspxt...uthCookie.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Andy Sutorius" <an**@sutorius.com> wrote in message
news:%s*********************@twister.southeast.rr. com...
Hi,

For some reason the login.aspx webpage redirects to itself after a
successful login and not to the url in the address bar. I have stepped
through this with debug and it behaves as it is supposed to. What am I
overlooking? Try it.

http://www.sutorius.com/psyche
click the Administration link
username = user1
password = user1
private void cmdLogin_ServerClick(object sender, System.EventArgs e)
{
if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Value,chkPersistCookie
.Checked);

else

lblMsg.Text = "Invalid Log in";



Nov 19 '05 #3
Steve,

I don't understand how adding setauthcookie has an effect on the redirect.

Andy
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
It looks like you've forgotten to call SetAuthCookie.
Here's more info:
http://authors.aspalliance.com/aspxt...uthCookie.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

Nov 19 '05 #4
Bill,

Thanks for that. I forgot to put in an allow. This is what my web.config
looks like now. And I am still getting the same response. I am attempting to
control access into a subdirectory from the web.config in the root folder.
Any other ideas?

<location path="admin" allowOverride="false">
<!-- <location path="admin" allowOverride="true"> -->
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
Steve, doesn't the redirectfromloginpage call create the cookie for you?

Andy, I've also had this when my web.config is not set up correctly to deny anonymous users and *allow* authenticated users.

Bill

"Steve C. Orr [MVP, MCSD]" wrote:
It looks like you've forgotten to call SetAuthCookie.
Here's more info:
http://authors.aspalliance.com/aspxt...uthCookie.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Andy Sutorius" <an**@sutorius.com> wrote in message
news:%s*********************@twister.southeast.rr. com...
Hi,

For some reason the login.aspx webpage redirects to itself after a
successful login and not to the url in the address bar. I have stepped
through this with debug and it behaves as it is supposed to. What am I
overlooking? Try it.

http://www.sutorius.com/psyche
click the Administration link
username = user1
password = user1
private void cmdLogin_ServerClick(object sender, System.EventArgs e)
{
if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Value,chkPersistCookie .Checked);

else

lblMsg.Text = "Invalid Log in";



Nov 19 '05 #5
Looks pretty good at first blush. Any chance there's a web.config in the
subfolder too (that would override the root)?

Also, per your comment above, I'll be anxious to read Steve's response. I've
been working through all this same stuff lately. To me, redirectfromloginpage
is one of those times where asp.net does *too* much to make it easy, so you
don't really understand what's happening underneath. Afaik, it combines
creating the cookie, creating the authentication ticket stored in the cookie,
persisting them or not, and redirecting to the requested page. You can do all
these yourself if you understand what's happening, and you're forced to do
that in cases I run into all the time, such as wanting to name the cookie
myself, keeping multiple cookies, playing with timeout values per user, etc.
Best discussion I've seen of all this is in Esposito's Programming ASP.NET
(best discussion of most *anything* is in that book). There's also a ton of
great stuff in this forum.

Bill

"Andy Sutorius" wrote:
Bill,

Thanks for that. I forgot to put in an allow. This is what my web.config
looks like now. And I am still getting the same response. I am attempting to
control access into a subdirectory from the web.config in the root folder.
Any other ideas?

<location path="admin" allowOverride="false">
<!-- <location path="admin" allowOverride="true"> -->
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
Steve, doesn't the redirectfromloginpage call create the cookie for you?

Andy, I've also had this when my web.config is not set up correctly to

deny
anonymous users and *allow* authenticated users.

Bill

"Steve C. Orr [MVP, MCSD]" wrote:
It looks like you've forgotten to call SetAuthCookie.
Here's more info:
http://authors.aspalliance.com/aspxt...uthCookie.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Andy Sutorius" <an**@sutorius.com> wrote in message
news:%s*********************@twister.southeast.rr. com...
> Hi,
>
> For some reason the login.aspx webpage redirects to itself after a
> successful login and not to the url in the address bar. I have stepped
> through this with debug and it behaves as it is supposed to. What am I
> overlooking? Try it.
>
> http://www.sutorius.com/psyche
> click the Administration link
> username = user1
> password = user1
>
>
> private void cmdLogin_ServerClick(object sender, System.EventArgs e)
> {
> if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
>
>
> FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Value,chkPersistCookie > .Checked);
>
> else
>
> lblMsg.Text = "Invalid Log in";
>
>
>
>
>


Nov 19 '05 #6
*This might be a double-post (having system trouble), but here goes (again):*

Looks pretty good at first blush. Any chance there's a web.config in the
subfolder too (that would override the root)?

Also, per your comment above, I'll be anxious to read Steve's response. I've
been working through all this same stuff lately. To me, redirectfromloginpage
is one of those times where asp.net does *too* much to make it easy, so you
don't really understand what's happening underneath. Afaik, it combines
creating the cookie, creating the authentication ticket stored in the cookie,
persisting them or not, and redirecting to the requested page. You can do all
these yourself if you understand what's happening, and you're forced to do
that in cases I run into all the time, such as wanting to name the cookie
myself, keeping multiple cookies, playing with timeout values per user, etc.
Best discussion I've seen of all this is in Esposito's Programming ASP.NET
(best discussion of most *anything* is in that book). There's also a ton of
great stuff in this forum.

Bill

"Andy Sutorius" wrote:
Bill,

Thanks for that. I forgot to put in an allow. This is what my web.config
looks like now. And I am still getting the same response. I am attempting to
control access into a subdirectory from the web.config in the root folder.
Any other ideas?

<location path="admin" allowOverride="false">
<!-- <location path="admin" allowOverride="true"> -->
<system.web>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
</system.web>
</location>
"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:2D**********************************@microsof t.com...
Steve, doesn't the redirectfromloginpage call create the cookie for you?

Andy, I've also had this when my web.config is not set up correctly to

deny
anonymous users and *allow* authenticated users.

Bill

"Steve C. Orr [MVP, MCSD]" wrote:
It looks like you've forgotten to call SetAuthCookie.
Here's more info:
http://authors.aspalliance.com/aspxt...uthCookie.aspx
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Andy Sutorius" <an**@sutorius.com> wrote in message
news:%s*********************@twister.southeast.rr. com...
> Hi,
>
> For some reason the login.aspx webpage redirects to itself after a
> successful login and not to the url in the address bar. I have stepped
> through this with debug and it behaves as it is supposed to. What am I
> overlooking? Try it.
>
> http://www.sutorius.com/psyche
> click the Administration link
> username = user1
> password = user1
>
>
> private void cmdLogin_ServerClick(object sender, System.EventArgs e)
> {
> if (ValidateUser(txtUserName.Value,txtUserPass.Value) )
>
>
> FormsAuthentication.RedirectFromLoginPage(txtUserN ame.Value,chkPersistCookie > .Checked);
>
> else
>
> lblMsg.Text = "Invalid Log in";
>
>
>
>
>


Nov 19 '05 #7
Bill,

Thanks for the extra eyes. In fact there is a web.config in the subfolder
with the same deny/allow so I took it out. Getting the same action though.
I've got something silly turned on/off, I just know it.

I like this article and related code:
http://www.theserverside.net/article...Authentication

Andy
"Bill Borg" <Bi******@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
Looks pretty good at first blush. Any chance there's a web.config in the
subfolder too (that would override the root)?

Also, per your comment above, I'll be anxious to read Steve's response. I've been working through all this same stuff lately. To me, redirectfromloginpage is one of those times where asp.net does *too* much to make it easy, so you don't really understand what's happening underneath. Afaik, it combines
creating the cookie, creating the authentication ticket stored in the cookie, persisting them or not, and redirecting to the requested page. You can do all these yourself if you understand what's happening, and you're forced to do
that in cases I run into all the time, such as wanting to name the cookie
myself, keeping multiple cookies, playing with timeout values per user, etc. Best discussion I've seen of all this is in Esposito's Programming ASP.NET
(best discussion of most *anything* is in that book). There's also a ton of great stuff in this forum.

Bill

Nov 19 '05 #8
It's behaving like the cookie isn't being set.
This is a way to explicitly set the cookie, so I thought it would be worth a
try. Then you can do a standard redirect and see if it works.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Andy Sutorius" <an**@sutorius.com> wrote in message
news:c_**************@twister.southeast.rr.com...
Steve,

I don't understand how adding setauthcookie has an effect on the redirect.

Andy
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
It looks like you've forgotten to call SetAuthCookie.
Here's more info:

http://authors.aspalliance.com/aspxt...uthCookie.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net


Nov 19 '05 #9

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

Similar topics

2
by: Ben Fidge | last post by:
Is FormsAuthentication.RedirectFromLoginPage the only way to populate the HttpContext.Current.User.Identity.Name property? A base class for each page contains the follwoing property: public...
3
by: Phil Certain | last post by:
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
2
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: ...
2
by: Grant Merwitz | last post by:
Hi, i am using forms authentication in an ASP.NET project I am setting the Forms authentication cookie by using: FormsAuthentication.RedirectFromLoginPage(UserName.Text, false); Now when i...
5
by: BoltonWolf | last post by:
Hi, I have a ASP.Net web site, that we sell as a module to our core software, versions of this site are running fine on many servers, however we are having problems with our latest installtion,...
1
by: Dean R. Henderson | last post by:
I setup FormsAuthentication on a couple websites where it has been working as expected for a long time. I used this code to setup the same type of authentication on a new website I am working on...
1
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...
0
by: Imran Aziz | last post by:
Hello All, I cannot seem to get createPersistentCookie option of FormsAuthentication.RedirectFromLoginPage work. Even if I set it to true the cookie is setup to expire after 30 min ( default...
2
by: rn5a | last post by:
A web.config file has the following code: <configuration> <system.web> <authentication mode="Forms"> <forms name="NETConnectCookie" loginUrl="Login.aspx"> <credentials passwordFormat="SHA1"/>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.