473,386 Members | 2,114 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,386 software developers and data experts.

FormsAuthentication.RedirectFromLoginPage is not redirecting to the correct page.

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 FormsAuthentication.RedirectFromLoginPage call is
redirecting to the default.aspx page rather than the original page the user
was at.

Here is the details of my application:

Web.config:
<authentication mode="Forms">
<forms name="Login.APSXAUTH"
loginUrl="login.aspx"
timeout="20"
protection="All"
path="/"/>
</authentication>

In each page of my application (with the exception of the login.aspx)
checks a variable in the Session. If the value is null, then a call to
Response.Redirect("login.aspx",false) is done.

When inspecting Request object in the page load of login.aspx when the
redirect first takes place, I can see that the URLReferrer is correct.

I then enter my credentials in the login page, and click a submit button.
When inspecing the Request object in the submit button click event at this
point, the URLReferrer points to my default.aspx page, not the page that
originally redirected me to the login.aspx page. As well, if I make a call
to FormsAuthentication.GetRedirectUrl, it returns the default.aspx. Making a
call to FormsAuthentication.RedirectFromLoginPage(username , false) redirects
me to the default.aspx and not the original page I was browsing. Is there
some additional things I need to do to determine the correct page to
redirect to?

Nov 19 '05 #1
1 3738
I handle this kind of functionality in a Session variable
(Page.Session("ReturnURL")). I set this value to the
Request.URL.ToString() in the header.ascx control that's placed on all
my pages. If this Session variable = Nothing when I exec the login
procedure, then I redirect to the default page, otherwise I redirect
to the URL stored in the Session variable. There's some other code in
there to disregard the login page as a RedirectURL and some other
functionality that was needed but not necessarily pertinent to this
case.
HTH

Nov 19 '05 #2

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: ...
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...
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...
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: 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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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.