Hello,
I have a problem with masterpages and forms security.
I made a new Web site, in which I have my page of login like of beginning, a
master page with only a sitemappath object in it, the file of map of the
site,
the web.config and another page to do tests.
In the page redirected from login there are a label and a combo (dropdown)
object
and the only thing this page do is to modify label with the text that this
one has
The problem is that it again redirects me to the login page, i singn in
again an then
the page redirects me to the initial state of the second page, but i nees
that this redirect
to the login page only happens when the 5 minutes timeout is reached.
I put my code down to them, hopefully you see something that is I making
wrong
hanking for beforehand your time and help.
Sergio E.
---------codigo del login.aspx
<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Login .aspx.vb"
Inherits="Login " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Login</title>
<link href="Styles/MiStyleSheet.cs s" rel="stylesheet " type="text/css" />
</head>
<body>
<form id="Form1" runat="server" method="post">
<div style="text-align: center">
<asp:Label ID="Label1" runat="server" Text="Reportead or"></asp:Label><br />
<br />
Acceso al Sistema<br />
<table style="width: 395px">
<tr>
<td style="width: 188px">
Usuario:
</td>
<td style="width: 199px">
<asp:TextBox ID="TxtUsuario " runat="server"
Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 188px">
Clave:</td>
<td style="width: 199px">
<asp:TextBox ID="TxtPwd" runat="server" TextMode="Passw ord"
Width="150px"></asp:TextBox></td>
</tr>
</table>
<asp:RequiredFi eldValidator ID="RequiredFie ldValidator1" runat="server"
ControlToValida te="TxtUsuario "
Display="None" ErrorMessage="E l campo Usuario no debe estar
vacío."></asp:RequiredFie ldValidator>
<asp:RequiredFi eldValidator ID="RequiredFie ldValidator2" runat="server"
ControlToValida te="TxtPwd"
Display="None" ErrorMessage="E l campo Clave no debe estar
vacío."></asp:RequiredFie ldValidator><br />
<asp:Validation Summary ID="ResumenVali dacion" runat="server" Height="85px"
ShowMessageBox= "True"
ShowSummary="Fa lse" Width="153px" />
<br />
<asp:Button ID="BtnLogin" runat="server" Text="Ingresar" /><br />
<br />
<br />
<asp:Label ID="LblError" runat="server" ForeColor="Red" Text="¡¡¡Error:
Usuario o Clave incorrectos!!!"
Visible="False" ></asp:Label>  ;</div>
</form>
</body>
</html>
--- codigo en la pagina de login.aspx.vb que define la cookie
Protected Sub BtnLogin_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles BtnLogin.Click
dim bUsuarioValido as boolean = ValidaUsuarioEn BDD() 'Este metodo es el que
se conecta a la base de datos y valida realmente al usuario
dim NomPaginaOk as string = "~/Reporte.aspx"
If Not (bUsuarioValido ) Then
Me.LblError.Vis ible = True
Me.TxtUsuario.T ext = ""
Me.TxtPwd.Text = ""
Else
FormsAuthentica tion.SetAuthCoo kie(Me.TxtUsuar io.Text, True)
Session.Add(Var iablesGlobales. NombreVarSesion EstadoAutorizad o,
VariablesGlobal es.ValorEsperad oSesionEstadoAu torizado)
Server.Transfer (NomPaginaOk,Tr ue)
End If
-------------- codigo de la pagina maestra
<%@ Master Language="VB" CodeFile="Heade r.master.vb" Inherits="Heade r" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Report e</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: left">
<center <strong>REPORTE ADOR</strong></center<br />
<asp:SiteMapPat h ID="smpMiSitio " runat="server" Font-Names="Verdana"
Font-Size="0.8em"
PathSeparator=" : ">
<PathSeparatorS tyle Font-Bold="True" ForeColor="#990 000" />
<CurrentNodeSty le ForeColor="#333 333" />
<NodeStyle Font-Bold="True" ForeColor="#990 000" />
<RootNodeStyl e Font-Bold="True" ForeColor="#FF8 000" />
</asp:SiteMapPath >
<br />
<br />
<asp:contentpla ceholder id="phContenido " runat="server">
</asp:contentplac eholder>
</div>
<br />
<strong><em><sp an style="text-decoration: underline">(C) Todos los derechos
reservados...</span></em></strong>
</form>
</body>
</html>
---------- codigo del archivo reporte.aspx
<%@ Page Language="VB" MasterPageFile= "~/Header.master"
AutoEventWireup ="false" CodeFile="Repor te.aspx.vb" Inherits="Repor te"
title="Reporte" %>
<asp:Content ID="Content1" ContentPlaceHol derID="phConten ido"
Runat="Server">
<asp:Label ID="lblEtiqueta " runat="server" Text="Label"></asp:Label>
<asp:DropDownLi st ID="DropDownLis t1" runat="server" AutoPostBack="T rue">
<asp:ListItem>h ola</asp:ListItem>
<asp:ListItem>c ompa</asp:ListItem>
</asp:DropDownLis t>
</asp:Content>
--------- codigo del archivo reporte.aspx.vb
Partial Class Reporte
Inherits System.Web.UI.P age
Protected Sub DropDownList1_S electedIndexCha nged(ByVal sender As Object,
ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
Me.lblEtiqueta. Text = Me.DropDownList 1.SelectedItem. Text
End Sub
End Class
------------ codigo del archivo web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microso ft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Login.aspx " title="" description="Ac ceso al Sistema">
<siteMapNode url="Reporte.as px" title="Inicio" description="Re porte">
</siteMapNode>
</siteMapNode>
</siteMap>
--------codigo del archivo web.config
<?xml version="1.0"?>
<configuratio n>
<appSettings/>
<connectionStri ngs>
<add name="AConnecti onString" connectionStrin g="Data
Source=DBServer 001;Initial Catalog=DBVenta s;Persist Security Info=True;User
ID=sa;Password= sa;Connect Timeout=60" providerName="S ystem.Data.SqlC lient"/>
</connectionStrin gs>
<system.web>
<compilation debug="true" strict="true" explicit="true"/>
<pages>
<namespaces>
<clear/>
<add namespace="Syst em"/>
<add namespace="Syst em.Collections"/>
<add namespace="Syst em.Collections. Specialized"/>
<add namespace="Syst em.Configuratio n"/>
<add namespace="Syst em.Text"/>
<add namespace="Syst em.Text.Regular Expressions"/>
<add namespace="Syst em.Web"/>
<add namespace="Syst em.Web.Caching"/>
<add namespace="Syst em.Web.SessionS tate"/>
<add namespace="Syst em.Web.Security "/>
<add namespace="Syst em.Web.Profile"/>
<add namespace="Syst em.Web.UI"/>
<add namespace="Syst em.Web.UI.WebCo ntrols"/>
<add namespace="Syst em.Web.UI.WebCo ntrols.WebParts "/>
<add namespace="Syst em.Web.UI.HtmlC ontrols"/>
</namespaces>
</pages>
<authenticati on mode="Forms">
<forms loginUrl="Login .aspx" name=".rptcooki e" timeout="5" >
<!--protection="All " timeout="1">-->
</forms>
</authentication>
<authorizatio n>
<deny users="?"/>
</authorization>
<customErrors mode="Off"/>
</system.web>
</configuration>