Advertisement

04.07.2008 at 09:59AM PDT, ID: 23301982
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Login.aspx not redirecting using Forms authentication??? -- Same problem

Asked by sonofgerale in Active Server Pages (ASP), Programming for ASP.NET

Very unusual problem suddenly occuring on our Windows 2003 server.

This has never been a problem, so it's a mystery to us.

The only thing different was opening the aspx web site using VS2008 instead of our trusty VS2005.

Q. Is this a cookie issue?

Our login Form to our downloads page will not work correctly from any computer other than using IE 7 on the server.

No errors of any kind and no redirect from the login.aspx to the default.asps either. The login page blinks very fast as if its redirecting back to itself....

We use FORMS authentication, all the typical stuff like so...

   FormsAuthentication.RedirectFromLoginPage(txtEmail.Value, true); // redirects to web.config "defaultUrl"            

[web.config]
<system.web>
    <authentication mode="Forms">
       <forms name=".ourcompany"
          loginUrl="/store/login.aspx"
          defaultUrl="/store/default.aspx"
          protection="All"
          timeout="30"
          path="/"/>
    </authentication>


Greetings,

Greetings,

 

I have the same issue as decribed above. There is this windows xp machine with .Net 2.x and IE7 installed as well as Firefox, a test machine. From this workstation I have always been able to access a web app, for a long time now.  The application encapsulates some logic and provides access to MS Reporting services reports. The c# application uses Forms Authentication, as does the Reporting Services service, so there are two authentication tickets per response from the web server. Just recently the test machine transitioned into state where it does not like cookies.

 

When the login submit process occurs in the client there is no response, just a page refresh. I can duplicate this on every xp machine in the world by following the steps below:

*Open Internet Explorer

*Select the Tools|Internet Options menu item (This opens the Internet Options Dialog)

*Select the privacy tab on the Internet Options Dialog

*Choose the Block All Cookies settings from the settings slider.

 

I do receive the 401-302 redirect translation from forms, then thats it, plop, back to the login page. I have set all security settings to the lowest level and tried everything else I could think of. For some damn reason IE is acting like it does not like my cookies, while accept cookies from other sites. Firefox is running smooth on this xp machine and the reports are being rendered and delivered without a problem.

 

Anyone have any ideas or suggestions on what could cause this problem. I have uninstalled and reinstalled IE7 and .NET. In my trace logs, the redirect page, main.aspx, is accessed after login.aspx and the server seems like it is responding with images and resources used in the main.aspx page, but all of the sudden it is back to ligin.aspx.

 I can not use the solution described above because I call response.Redirect instead of FormsAuthentication.RedirectFromLogin(), see code attached.

Thanks,
Ross

Ross

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
HERE IS THE LOGIN ASPX CODE AFTER THE USER HAS BEEN AUTHENTICATED
 
FormsAuthentication.Initialize();
      FormsAuthentication.HashPasswordForStoringInConfigFile(edtPassword.Text,"md5");
      // Create a new ticket used for authentication
      FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(
                                             1,                           // Ticket version
                                             Convert.ToString(UserID),    // Username associated with ticket
                                             DateTime.Now,                // Date/time issued
                                             DateTime.Now.AddMinutes(30), // Date/time to expire
                                             true,                        // "true" for a persistent user cookie
                                             UserRole,                    // User-data, in this case the roles
                                             FormsAuthentication.FormsCookiePath);// Path cookie valid for
 
      // Encrypt the cookie using the machine key for secure transport
      string Hash = FormsAuthentication.Encrypt(Ticket);
      HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, Hash);
      // Set the cookie's expiration time to the tickets expiration time
      if (Ticket.IsPersistent) Cookie.Expires = Ticket.Expiration;
      // Add the cookie to the list for outgoing response
      Response.Cookies.Add(Cookie);
      // Redirect to requested URL, or homepage if no previous page
      // requested
      //ReturnUrl = Request.QueryString["ReturnUrl"];
      string ReturnUrl="";      
      if (UserRole==c.RoleStudent)
        ReturnUrl = c.PageReportViewer;
      else
        ReturnUrl = c.PageMain;
        
      if (ReturnUrl == null) ReturnUrl = "/";
      // Don't call FormsAuthentication.RedirectFromLoginPage since it could replace the authentication ticket (cookie) we just added      
      Response.Redirect(ReturnUrl);
 
IN GLOBAL ASPX--------------------
void Application_AuthenticateRequest (Object sender, EventArgs e)
  {
    if (HttpContext.Current.User != null)
    {
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            if (HttpContext.Current.User.Identity is FormsIdentity)
            {
                FormsIdentity ID = (FormsIdentity)HttpContext.Current.User.Identity;
                FormsAuthenticationTicket Ticket = ID.Ticket;
                // Get the stored user-data, in this case, our roles
                string UserData = Ticket.UserData;
                string[] Roles = UserData.Split(',');
                HttpContext.Current.User = new GenericPrincipal(ID,Roles);
            }
        }
     }
  }
 
//---SNIPPET FROM MY CONFIG FILE FOR THE LOGIN APP
			<authentication mode="Forms">
				<forms name="ilrpts_frms_auth" loginUrl="Login.aspx" protection="All" slidingExpiration="true" timeout="20" path="/"/>
			</authentication>
      
			<customErrors mode="Off"/>
      
			<sessionState mode="InProc" timeout="60"/>
...
...
...
 
<location path="StateList.aspx">
			<system.web>
				<authorization>
					<allow roles="ILAdmin"/>
					<deny users="*"/>
				</authorization>
			</system.web>
...
		</location>
[+][-]04.07.2008 at 10:06AM PDT, ID: 21298703

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.07.2008 at 10:07AM PDT, ID: 21298713

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.07.2008 at 10:54AM PDT, ID: 21299066

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), Programming for ASP.NET
Sign Up Now!
Solution Provided By: sonofgerale
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_Related_20080208