473,395 Members | 1,454 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,395 software developers and data experts.

RedirectFromLoginPage not redirecting to RedirectUrl

Greetings,

I have encountered what appears to be a fairly common problem:
RedirectFromLoginPage is not redirecting to RedirectUrl. I have tried
all the advice that I could on the 'net, and nothing has worked yet. My
problem is very simple. I want to redirect from a login page to the
default page in one application. I am not crossing over to other
applications in other directories on the server.

Here is a description of the problem:
- Go to http://localhost/App1. From here, you are redirected to
http://localhost/App1/login.aspx. The Address bar says
http://localhost/App1/login.aspx?Ret...2fdefault.aspx

- Enter a username and a password. Click Login.

- You remain at the page http://localhost/App1/login.aspx. However, the
Address bar now reads http://localhost/App1/default.aspx.
I am unable to get the application to redirect to default.aspx after
successfully logging in. After logging in, if I try to manually go to
default.aspx, I am redirected to login.aspx.
Here are the details of my situation:
- I am running Microsoft Visual C# .NET (Microsoft Visual Development
Environment 2003) on XP, using IIS 5.1.

- I have an application named 'App1' located at
c:\inetpub\wwwroot\App1.

- Inside c:\inetpub\wwwroot\App1\ I have:
- default.aspx
- login.aspx

- Here is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="true" />
<customErrors mode="RemoteOnly" />
<authentication mode="Forms">
<forms name=".App1" loginUrl="login.aspx" protection="All"
path="/">
</forms>
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<trace enabled="false" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />
<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes" cookieless="false"
timeout="20" />
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</system.web>
</configuration>

- Here are the critical contents of login.aspx:
<form id="LoginForm" method="post" runat="server">
<TABLE id="LoginTable" cellSpacing="0" cellPadding="4" border="0">
<TR>
<TD align="right"><STRONG>Email address:</STRONG></TD>
<TD width="2%"></TD>
<TD><asp:textbox id="EmailAddressTextBox" tabIndex="1"
runat="server" Columns="18" MaxLength="256"></asp:textbox></TD>
</TR>
<TR>
<TD align="right"><STRONG>Password</STRONG>:</TD>
<TD></TD>
<TD><asp:textbox id="PasswordTextBox" tabIndex="2" runat="server"
Columns="18" MaxLength="16" TextMode="Password"></asp:textbox></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD align="right"><asp:button id="LoginButton" tabIndex="4"
runat="server" Text="Login"></asp:button></TD>
</TR>
</TABLE>
</form>

- Here is the LoginButton method:
private void LoginButton_Click(object sender, System.EventArgs e)
{
if ( IsValid )
{
FormsAuthentication.RedirectFromLoginPage( "John", false );
}
}

- If I right-click and get the properties from Explorer for
c:\inetpub\wwwroot\App1\, under the Web Sharing tab, "Share this
folder" is selected and the alias listed is 'App1'.

- In IIS Manager, if I right-click on App1, under the 'Virtual
Directory' tab, 'App1' is the Application Name. Clicking the Directory
Security tab and then Edit for 'Anonymous access and authentication
control', the 'Anonymous access' checkbox is selected with an
appropriate IUSR_xxx user name.
That about somes up my current situation. I have spent several hours on
this and have no clue how to fix the problem. Any help is greatly
appreciated. Please let me know if you need any more information to
help diagnose the problem.

Thanks,

-=John

Nov 19 '05 #1
4 3423
I have tried debugging the situation and learned that authentication
does appear to be occuring. I put the following in my global.asax.cs:
protected void Application_AuthenticateRequest(Object sender,
EventArgs e)
{
HttpApplication theApp = (HttpApplication) sender;

if( theApp.Request.IsAuthenticated && theApp.User.Identity is
FormsIdentity )
{
FormsIdentity theIdentity = (FormsIdentity) theApp.User.Identity;
}

if(HttpContext.Current.User != null)
{
if(HttpContext.Current.User.Identity.IsAuthenticat ed)
{
if(HttpContext.Current.User.Identity is FormsIdentity)
{
FormsIdentity id =
(FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;

// get data stored in cookie
string userData = ticket.UserData;
string[] roles = userData.Split(',');
HttpContext.Current.User = new GenericPrincipal(id, roles);
}
}
}
}

Initially, the code inside the nested if statements does not execute.
After RedirectFromLoginPage is called and the page is reloaded, the
code inside the nested if statements does execute. So, it appears that
authentication is occuring.

-=John

Nov 19 '05 #2
More info: I have tried both IE and Firefox. Both browsers encounter
the problem.

-=John

Nov 19 '05 #3
More info: I have tried replacing localhost with the IP address of the
machine. Still experiencing the problem.

-=John

Nov 19 '05 #4
John in ur web.config:-
<forms name=".App1" loginUrl="login.aspx" protection="All"
path="/">
Is ur cookie name = .App1?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #5

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

Similar topics

0
by: Rob O'Cop | last post by:
Hi, I've got an Intranet site that's been using the usual Forms authentication. Now, I want to retrieve the Windows Login and authenticate the user automatically without her typing...
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...
2
by: Rob O'Cop | last post by:
Hi, I've got an Intranet site that's been using the usual Forms authentication. Now, I want to retrieve the Windows Login and authenticate the user automatically without her typing...
8
by: Andy Sutorius | last post by:
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...
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,...
9
by: Sandy | last post by:
Any help anyone can give me will be appreciated!!!! This is driving me c-r-a-z-y! All I can get from both of the above redirections is a redirect to a page named default.aspx. How do I make...
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: Ryan | last post by:
I have an aspx form using: FormsAuthentication.RedirectFromLoginPage("LoginName", False) When the form is browsed to for the VERY first time, instead of redirecting the user to the original...
2
by: genc ymeri | last post by:
hi, I'm doping a maintenance for a project but I'm having an interesting issue with RedirectFromLoginPage coomand :) What happens is that the webapp, once user logs in, he/she goes gets...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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
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.