I have developed a .NET 4.0 ASP.NET website. All working great locally. Developed on IIS7.5, WS2008R2 Enterprise + all updates.
I deploy to WS2003 server. All almost works except, when I am logging into the website (Forms auth) it redirects me back to the login page! No errors, no nothing. Sometimes when I manage to get through that, and navigate to another page or perform an action like a click of a button, I get redirected back to the login page!
Convinced there was a problem with the server setup, the IT guy installed WS2008R2 + all updates. Great - so I deployed the website on to that. Guess what? STILL THE SAME PROBLEM!
what gives? Why on earth would it redirect back to the login page when you login (no code to do that) or when you perform an action?
The other thing is, I am using the Telerik control and also the ASP.NET AJAX extenders. The server doesn't seem to load them (no errors on both server and client). There are supposed to be drop down menus and that does not work in addition to the AJAX calendar to popup - that does not work either.
I am not sure what to do now as this is frustrating and NEVER have I run into such a problem.
here is part of my config file:
<configSections>
<sectionGroup name="system.web">
<section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
</sectionGroup>
</configSections>
<system.web>
<globalization culture="en-gb" uiCulture="en-gb"/>
<httpRuntime maxRequestLength="100240"/>
<trust level="Full"/>
<sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
<providers>
<add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"/>
</providers>
</sanitizer>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Telerik.Web.UI, Version=2012.3.1017.40, Culture=neutral, PublicKeyToken=949410a6b6ad1e71"/>
</assemblies>
</compilation>
<sessionState mode="InProc" timeout="30"/>
<authentication mode="Forms">
<forms name="RegisteredUsers" defaultUrl="~/Help/About.aspx" path="/" protection="All" loginUrl="~/Account/Login.aspx" timeout="31"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<httpHandlers>
<add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/>
</httpHandlers>
</system.web>
<location path="Account">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Public">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Styles">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Scripts">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Images">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Help">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource"/>
</handlers>
</system.webServer>
As for the authentication code:
// log them in and authenticate
FormsAuthentication.SetAuthCookie(this.txtUsername.Text, false);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, this.txtUsername.Text, DateTime.Now, DateTime.Now.AddYears(1), false, this.txtUsername.Text);
// For security reasons we may hash the cookies
string hashCookies = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies);
cookie.Path = FormsAuthentication.FormsCookiePath;
cookie.Expires = ticket.Expiration;
// add the cookie to user browser
Response.Cookies.Add(cookie);
Session[CommonStrings.USER_LOGGED_IN] = userResponse.User;
// if DefaultWebPage is not null then redirect to that otherwise, default behavior.
if (!string.IsNullOrWhiteSpace(userResponse.User.DefaultWebPage))
{
Response.Redirect(userResponse.User.DefaultWebPage, false);
}
else
{
FormsAuthentication.RedirectFromLoginPage(this.txtUsername.Text, false);
}