I've been tasked with moving a .NET 3.5 application from some of our old servers to their new home on an IIS 8.5 level server and, unsurprisingly, some of them simply won't run.
To mitigate this, I've imported all of the files into a new project and run through all of the errors, warnings and messages, ironing out the problems.
The application now starts, however, the login process (typical .NET login process, using FormsAuthentication.RedirectFromLoginPage(UserName.Text, True)
simply doesn't work; it will not authenticate the user.
The web.config file has the following entry in the authorization
section:
<anonymousIdentification enabled="false" />
...
<httpModules>
<add name="ScriptModule"
type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35"/>
<add name="FormsAuthentication"
type="System.Web.Security.FormsAuthenticationModule" />
</httpModules>
...
<authentication mode="Forms">
<forms loginUrl="Default.aspx"
defaultUrl="default.aspx"
slidingExpiration="true"
timeout="20"
name="FORMSAUTHCOOKIE"
protection="All" />
</authentication>
...
<authorization>
<allow users="*"/>
<deny users="?"/>
</authorization>
I've modified the code behind with some dummy variables for me to monitor with watches etc...
1 If row.ItemArray.Length <> 0 And Not row("Suspended") Then
2 Session("isadmin") = row("Administrator")
3 Session("email") = row("Email")
4 Session("welcome") = row("Forename") & " " & row("Surname") & " (" & row("Department") & "), logged in"
5 uAdapter.UpdateLastLogin(row("UserName"), row("Password"))
6 FormsAuthentication.RedirectFromLoginPage(UserName.Text, True)
7 Dim y As Boolean = Request.IsAuthenticated
8 Dim x As HttpCookieCollection = Request.Cookies
9 Dim z As HttpCookie = Request.Cookies.Item("FORMSAUTHCOOKIE")
10 Dim a As Int32 = -1
11 Else
12 Msg.Text = "Invalid login details. Please try again."
13 End If
Lines 7 through 10 are for testing and reading other values that are not present in the code. Despite the FormsAuthentication.RedirectFromLoginPage(UserName.Text, True)
executing without error, it does not redirect to any other page than the current, even if there's a referral from elsewhere. Also, line 7, on execution, has a False result.
There are no error messages. The data is being returned from the connection. There is a difference in formatting between the two versions of the system, but I put this down to the rendering on IIS.
Can anyone spot anything obvious as to why this wouldn't work? Have I missed something somewhere?
Further Details
Further to David's answer, below, I have tested with a direct ReturnUrl and stepped through the code...