Jun 04, 2012, 2:04 PM
[CLOSED] Forms authentication RedirectFromLoginPage not working
Hi,
New project, new problems :)
I'm using forms authentication in this new project. The FormsAuthentication.RedirectFromLoginPage code, doesn't redirect me to the initial page , but when failure the messagebox opens.. so that works. Any idea ?
These are my settings in the web.config:
New project, new problems :)
I'm using forms authentication in this new project. The FormsAuthentication.RedirectFromLoginPage code, doesn't redirect me to the initial page , but when failure the messagebox opens.. so that works. Any idea ?
These are my settings in the web.config:
<authentication mode="Forms">
<forms
loginUrl="Login.aspx"
defaultUrl="Default.aspx"
slidingExpiration="true"
timeout="60"
name=".Auth"
protection="All">
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
I've added this to the global.asaxprotected void Application_AuthenticateRequest(object sender, System.EventArgs e)
{
string url = HttpContext.Current.Request.RawUrl.ToLower();
if (url.Contains("ext.axd") || url.Contains(".css"))
{
HttpContext.Current.SkipAuthorization = true;
}
}
and this is the login page (html)<%@ Page Language="C#" CodeFile="Login.aspx.cs" Inherits="Login" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Inloggen CarWise Support</title>
<link href="Style/StyleSheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" CleanResourceUrl="false"/>
<ext:Window ID="winLogim"
runat="server"
Width="350"
Height="120"
Title="Inloggen CarWise Support"
Icon="LockAdd"
Closable="false"
BodyPadding="5"
Layout="Form">
<Defaults>
<ext:Parameter Name="LabelWidth" Value="125" Mode="Raw" />
</Defaults>
<Items>
<ext:NumberField
ID="nfLogin"
runat="server"
FieldLabel="Login"
AnchorHorizontal="100%"
HideTrigger="true"
/>
<ext:TextField ID="tfPassword"
runat="server"
Vtype="password"
FieldLabel="Wachtwoord"
InputType="Password"
MsgTarget="Side"
AnchorHorizontal="100%"/>
<ext:Button ID="btnLogin" Text="Inloggen" runat="server">
<DirectEvents>
<Click OnEvent="Button_Click"/>
</DirectEvents>
</ext:Button>
</Items>
</ext:Window>
</form>
</body>
</html>
Codebehindusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
public partial class Login : System.Web.UI.Page
{
protected void Button_Click(object sender, DirectEventArgs e)
{
String cDebiteurID = nfLogin.Text;
String cPassword = tfPassword.Text;
if (cDebiteurID="1" && cPassword="password")
{
FormsAuthentication.RedirectFromLoginPage(cDebiteurID, false);
}
else
{
ExtNet.Msg.Alert("Foute login", "De door u gekozen combinatie is bij ons niet bekend.").Show();
}
}
}
Last edited by Daniil; Jun 04, 2012 at 4:15 PM.
Reason: [CLOSED]