<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-557902786835022368</id><updated>2026-08-02T13:01:09.253+02:00</updated><category term=".net"/><category term="asp.net"/><category term="ascx"/><category term="autenticacion"/><category term="control de usuario"/><category term="formulario"/><category term="seguridad"/><category term="css"/><category term="eventos"/><category term="roles"/><title type='text'>C# Experience</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-2588141830800156339</id><published>2010-01-08T00:58:00.001+01:00</published><updated>2010-01-08T01:06:54.002+01:00</updated><title type='text'>ASP.NET Llamar JavaScript desde C#</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;Voy a explicarte un ejemplo con un par de posibilidades para llamar a un método JavaScript desde tu código de servidor C#. La clave está en el método &quot;&lt;em&gt;RegisterStartupScript&lt;/em&gt;&quot; que nos permite registrar un código JavaScript desde el código de C# y que éste sea interpretado por el navegador. Te puedes descargar el código de ejemplo &lt;a href=&#39;http://javascriptcsharp.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=38407&#39;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;La primera posibilidad es que quieras invocar un método JavaScript desde el Page_Load de tu página ASPX, para ello puedes hacer lo siguiente:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;color:gray; font-family:Courier New; font-size:10pt&#39;&gt;///&amp;lt;summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:gray&#39;&gt;///&lt;/span&gt;&lt;span style=&#39;color:green&#39;&gt; Evento de carga de la página&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:gray; font-family:Courier New; font-size:10pt&#39;&gt;///&amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:gray&#39;&gt;///&lt;/span&gt;&lt;span style=&#39;color:green&#39;&gt;&lt;br /&gt;										&lt;/span&gt;&lt;span style=&#39;color:gray&#39;&gt;&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:gray&#39;&gt;///&lt;/span&gt;&lt;span style=&#39;color:green&#39;&gt;&lt;br /&gt;										&lt;/span&gt;&lt;span style=&#39;color:gray&#39;&gt;&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;protected&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; Page_Load(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender, &lt;span style=&#39;color:#2b91af&#39;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se llama a un javascript cuando la página carga&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; mensaje = &lt;span style=&#39;color:#a31515&#39;&gt;&quot;Este mensaje se genera desde c#&quot;&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;ClientScript.RegisterStartupScript(&lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.GetType(), &lt;span style=&#39;color:#a31515&#39;&gt;&quot;myScript&quot;&lt;/span&gt;, &lt;span style=&#39;color:#a31515&#39;&gt;&quot;&amp;lt;script&amp;gt;javascript:mostrarMensaje(&#39;&quot;&lt;/span&gt; + mensaje + &lt;span style=&#39;color:#a31515&#39;&gt;&quot;&#39;);&amp;lt;/script&amp;gt;&quot;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;La segunda posibilidad es que quieras ejecutar un método JavaScript desde el evento de un control de tu página ASPX:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;color:gray; font-family:Courier New; font-size:10pt&#39;&gt;///&amp;lt;summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:gray&#39;&gt;///&lt;/span&gt;&lt;span style=&#39;color:green&#39;&gt;El botón va a ejecutar un código javascript&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:gray; font-family:Courier New; font-size:10pt&#39;&gt;///&amp;lt;/summary&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:gray; font-family:Courier New; font-size:10pt&#39;&gt;///&amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:gray; font-family:Courier New; font-size:10pt&#39;&gt;///&amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;protected&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; btnClick_Click(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender, &lt;span style=&#39;color:#2b91af&#39;&gt;EventArgs&lt;/span&gt; e)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se genera el código javascript que se quiere ejecutar&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;System.Text.&lt;span style=&#39;color:#2b91af&#39;&gt;StringBuilder&lt;/span&gt; sb = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt; System.Text.&lt;span style=&#39;color:#2b91af&#39;&gt;StringBuilder&lt;/span&gt;();&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sb.Append(&lt;span style=&#39;color:#a31515&#39;&gt;@&quot;&amp;lt;script language=&#39;javascript&#39;&amp;gt;&quot;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sb.Append(&lt;span style=&#39;color:#a31515&#39;&gt;@&quot;var lbl = document.getElementById(&#39;lblMensaje&#39;);&quot;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sb.Append(&lt;span style=&#39;color:#a31515&#39;&gt;@&quot;lbl.style.color=&#39;red&#39;;&quot;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sb.Append(&lt;span style=&#39;color:#a31515&#39;&gt;@&quot;alert(lbl.innerText);&quot;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sb.Append(&lt;span style=&#39;color:#a31515&#39;&gt;@&quot;&amp;lt;/script&amp;gt;&quot;&lt;/span&gt;);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (!ClientScript.IsStartupScriptRegistered(&lt;span style=&#39;color:#a31515&#39;&gt;&quot;JSScript&quot;&lt;/span&gt;))&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;ClientScript.RegisterStartupScript(&lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.GetType(), &lt;span style=&#39;color:#a31515&#39;&gt;&quot;JSScript&quot;&lt;/span&gt;, sb.ToString());&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Espero que te sea de utilidad y recuerda que puedes descarte el código &lt;a href=&#39;http://javascriptcsharp.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=38407&#39;&gt;aquí&lt;/a&gt;.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/2588141830800156339/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-llamar-javascript-desde-c.html#comment-form' title='15 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/2588141830800156339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/2588141830800156339'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-llamar-javascript-desde-c.html' title='ASP.NET Llamar JavaScript desde C#'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-1438405932369184833</id><published>2010-01-08T00:18:00.002+01:00</published><updated>2010-01-08T00:25:10.908+01:00</updated><title type='text'>ASP.NET Depurar JavaScript</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;En este post te voy a explicar cómo depurar un Java Script.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Depurarlo no es complicado, basta simplemente con incluir una instrucción &quot;&lt;em&gt;debugger&lt;/em&gt;;&quot; dentro de tu código de JavaScript, de esta forma, cuando este código pase a ejecutarse el depurador de Visual Studio se parará tal como lo hace en un break-point de tu código C#.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:579px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;script &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;language&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;javascript&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;type&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;text/javascript&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;function&lt;/span&gt; mostrarMensaje(mensaje) &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;debugger&lt;/span&gt;; &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;alert(mensaje); &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;script&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Como puedes ver en la siguiente imagen Visual Studio te permite incluso de explorar los valores de tus variables dentro de tu JavaScript:&lt;br /&gt;&lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;a href=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ExEV6pjWzuOra5diO61fOVc7JnrUyepTsg9fs8CVfAFUZw5cflthwtAc3tHDoZJXBPMxQ6HFJchWQERwPebZ2IrC4fkK1_uCkUpb3GkwmmX6dLcqQ7IixZmNwFxeFuNuSApPPAFPj4EY/s1600-h/aspnet_depurando_javascript.PNG&#39;&gt;&lt;img border=&#39;0&#39; alt=&#39;&#39; src=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ExEV6pjWzuOra5diO61fOVc7JnrUyepTsg9fs8CVfAFUZw5cflthwtAc3tHDoZJXBPMxQ6HFJchWQERwPebZ2IrC4fkK1_uCkUpb3GkwmmX6dLcqQ7IixZmNwFxeFuNuSApPPAFPj4EY/s320/aspnet_depurando_javascript.PNG&#39;/&gt;&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Espero que te sirva!&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/1438405932369184833/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-depurar-javascript.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/1438405932369184833'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/1438405932369184833'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-depurar-javascript.html' title='ASP.NET Depurar JavaScript'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ExEV6pjWzuOra5diO61fOVc7JnrUyepTsg9fs8CVfAFUZw5cflthwtAc3tHDoZJXBPMxQ6HFJchWQERwPebZ2IrC4fkK1_uCkUpb3GkwmmX6dLcqQ7IixZmNwFxeFuNuSApPPAFPj4EY/s72-c/aspnet_depurando_javascript.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-5487634064396132785</id><published>2010-01-06T22:43:00.001+01:00</published><updated>2010-01-06T22:44:17.402+01:00</updated><title type='text'>ASP.NET Ajax - Añadir triggers a un UpdatePanel dinámicamente</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;Este post te será útil en el caso de que estés interesado en añadir eventos como triggers de Update Panels programáticamente en tiempo de ejecución.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Cuando se añaden Triggers a un update panel en tiempo de diseño, el aspecto de nuestra página será el siguiente:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;UpdatePanel&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;UpdatePanel1&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ChildrenAsTriggers&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;False&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;UpdateMode&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Conditional&quot;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;ContentTemplate&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;Button&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;BtnAcceptar&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;Text&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Aceptar&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;OnClick&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;BtnAcceptar_Click&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;ContentTemplate&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;Triggers&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;AsyncPostBackTrigger&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ControlID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;BtnAcceptar&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;EventName&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Click&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;Triggers&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:9pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;UpdatePanel&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Si tus necesidades precisan que estos triggers sean añadidos en tiempo de ejecución utiliza el siguiente código: &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;AsyncPostBackTrigger&lt;/span&gt; Trigger = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:#2b91af&#39;&gt;AsyncPostBackTrigger&lt;/span&gt;();&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:green&#39;&gt;//ControlID = ID del control que provoca el evento.&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;Trigger.ControlID = ControlID;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:green&#39;&gt;//EventName = Nombre del evento, p.e: Click, SelectedIndexChange.&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;Trigger.EventName = EventName;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:green&#39;&gt;//Se añade el trigger al update panel&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;UpdatePanel1.Triggers.Add(Trigger);&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Espero que te sea de utilidad!&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/5487634064396132785/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-ajax-anadir-triggers-un.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/5487634064396132785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/5487634064396132785'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-ajax-anadir-triggers-un.html' title='ASP.NET Ajax - Añadir triggers a un UpdatePanel dinámicamente'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-8318970690401861046</id><published>2010-01-06T21:43:00.001+01:00</published><updated>2010-01-06T22:11:28.830+01:00</updated><title type='text'>.NET Log en el Visor de Sucesos (Event Viewer)</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;En este post quiero mostrarte como utilizar el visor de sucesos como para persistir los eventos de tu aplicación.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;El soporte de Microsoft dice lo siguiente:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&quot;&lt;em&gt;Los registros de sucesos proporcionan un medio estándar y centralizado para que las aplicaciones graben sucesos (eventos) de software y hardware importantes. Windows suministra una interfaz de usuario estándar para ver los registros: el Visor de sucesos&lt;/em&gt;&quot; (&lt;a href=&#39;http://support.microsoft.com/kb/307024/es&#39;&gt;aquí&lt;/a&gt;)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;No quiero contradecirlos pero, en mi opinión, no tendríamos que abusar del uso del registro de sucesos por las siguientes razones:&lt;br /&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;El registro de sucesos se llena. A mí ya me ha ocurrido en una máquina XP, entiendo que en un servidor el tamaño será mucho más grande.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;La explotación de estadísticas. Es habitual querer obtener estadísticas de los eventos que provocan nuestras aplicaciones.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Mantenimiento de aplicaciones. El Visor de Sucesos muestra los eventos escritos por todas las aplicaciones del sistema, por tanto es más difícil encontrar el evento que buscamos.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Mi recomendación sería usar una base de datos para persistir nuestros logs del tipo que sean (auditoría, errores, informativos…), para poder explotar estos datos. Aún así, los eventos informados en el registro de sucesos dan un aspecto más profesional a nuestras aplicaciones, pudiendo seleccionar ciertos eventos de nuestra aplicación que deberíamos persistir en el registro de eventos.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;El uso es sencillo lo podéis ver &lt;a href=&#39;http://support.microsoft.com/kb/307024/es&#39;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Sólo tienes que crear un nuevo proyecto usando la plantilla de &quot;&lt;em&gt;Aplicación del Consola&lt;/em&gt;&quot; y tener el código siguiente en tu clase Main:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;static&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; Main(&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt;[] args)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; sSource;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; sLog;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; sEvent;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sSource = &lt;span style=&#39;color:#a31515&#39;&gt;&quot;Nombre de mi aplicación&quot;&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sLog = &lt;span style=&#39;color:#a31515&#39;&gt;&quot;Application&quot;&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;sEvent = &lt;span style=&#39;color:#a31515&#39;&gt;&quot;Mensaje de nuestro evento&quot;&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se añade nuestra aplicación como generadora de eventos si esta no existe&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (!&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.SourceExists(sSource))&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.CreateEventSource(sSource, sLog);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se escribe una Advertencia/Warning&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.WriteEntry(sSource, sEvent, &lt;span style=&#39;color:#2b91af&#39;&gt;EventLogEntryType&lt;/span&gt;.Warning, 230);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se escribe un error&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.WriteEntry(sSource, sEvent, &lt;span style=&#39;color:#2b91af&#39;&gt;EventLogEntryType&lt;/span&gt;.Error, 231);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se escribe un error&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.WriteEntry(sSource, sEvent, &lt;span style=&#39;color:#2b91af&#39;&gt;EventLogEntryType&lt;/span&gt;.FailureAudit, 232);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se escribe un error&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.WriteEntry(sSource, sEvent, &lt;span style=&#39;color:#2b91af&#39;&gt;EventLogEntryType&lt;/span&gt;.Information, 233);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;//Se escribe un er&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventLog&lt;/span&gt;.WriteEntry(sSource, sEvent, &lt;span style=&#39;color:#2b91af&#39;&gt;EventLogEntryType&lt;/span&gt;.SuccessAudit, 234);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Una vez ejecutes la aplicación consulta el visor de sucesos de tu máquina: &lt;em&gt;Inicio &amp;gt; Ejecutar &amp;gt;eventvwr&lt;/em&gt;. Este tendrá el aspecto que puedes ver en la imagen siguiente:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;a href=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9UMRM05XzqLl9i_g_eurWau364nBRi5lrDK-IdMN7wN9LxVTu_A0MptNd6bYC8ETl_2VVs8DbzZHXRzYiwdoJ_vXPe2ojoN1LprMaw6pytS7_7D4EEm_PqbYkmI-kPQh9BWdXvOO5S5Nn/s1600-h/aspnet_log_visor_sucesos.PNG&#39;&gt;&lt;img border=&#39;0&#39; alt=&#39;&#39; src=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9UMRM05XzqLl9i_g_eurWau364nBRi5lrDK-IdMN7wN9LxVTu_A0MptNd6bYC8ETl_2VVs8DbzZHXRzYiwdoJ_vXPe2ojoN1LprMaw6pytS7_7D4EEm_PqbYkmI-kPQh9BWdXvOO5S5Nn/s320/aspnet_log_visor_sucesos.PNG&#39;/&gt;&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Espero que te sea útil este post y si tienes alguna duda realiza un comentario.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/8318970690401861046/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/net-log-en-el-visor-de-sucesos-event.html#comment-form' title='3 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/8318970690401861046'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/8318970690401861046'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/net-log-en-el-visor-de-sucesos-event.html' title='.NET Log en el Visor de Sucesos (Event Viewer)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9UMRM05XzqLl9i_g_eurWau364nBRi5lrDK-IdMN7wN9LxVTu_A0MptNd6bYC8ETl_2VVs8DbzZHXRzYiwdoJ_vXPe2ojoN1LprMaw6pytS7_7D4EEm_PqbYkmI-kPQh9BWdXvOO5S5Nn/s72-c/aspnet_log_visor_sucesos.PNG" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-7326931753259753996</id><published>2010-01-02T16:59:00.001+01:00</published><updated>2010-01-02T17:04:35.504+01:00</updated><title type='text'>ASP.NET WebParts</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;Échale un ojo a este vídeo, explica el uso de los WebParts. Imaginas como se puede mejorar la administración de un sitio si permitimos a un usuario administrador cambiar los paneles de un sitio a otro, cambiar sus propiedades…En mi opnión aún no sabemos sacarle todo el jugo a los WebParts, pero nos convendría pensar en ellos como una posible propuesta a nuestros clientes. De hecho SharePoint aprovecha todas las funcionalidades de estos WebParts para la administración de sus sitios.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&#39;http://www.asp.net/learn/3.5-videos/video-43.aspx&#39;&gt;Aquí tienes el vídeo&lt;/a&gt;, espero que te de algunas ideas de cómo utilizar los WebParts en tus aplicaciones.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/7326931753259753996/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-webparts.html#comment-form' title='2 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/7326931753259753996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/7326931753259753996'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2010/01/aspnet-webparts.html' title='ASP.NET WebParts'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-1468665034798491173</id><published>2009-12-31T04:53:00.001+01:00</published><updated>2009-12-31T14:51:49.600+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="ascx"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="control de usuario"/><category scheme="http://www.blogger.com/atom/ns#" term="eventos"/><title type='text'>ASP.NET - Eventos de Controles de Usuario (ASCX)</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;El código completo del ejemplo lo puedes encontrar &lt;a href=&#39;http://usercontrolevents.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=38016&#39;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;A la hora de crear controles de usuario solemos necesitar capturar un evento que se produce dentro del mismo, en la página padre. Además, normalmente, necesitaremos acceder a alguna de sus propiedades desde la página padre. En el ejemplo que os presento tenemos un control de usuario (un buscador) incrustado en una página que mostrará los resultados de la búsqueda.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Para ello el control de usuario posee un evento que se lanza una vez la búsqueda ha finalizado, además, los resultados de dicha búsqueda se almacenan en una propiedad del control de usuario que recupera la página para mostrarlos en un GridView.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Pasemos al código. El control de usuario, en su parte visual se compone únicamente de un TextBox (donde introducir el criterio de búsqueda) y un Button (que realiza la búsqueda).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;a href=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNEimd9_rVOsWkN44lKq9Q-kGNd5W3e3bkNj7FR4bpimY-4Q3J2rHh4RKIP-wag26Y7-ef5aQ14ALGFh0lrz6dFbd_EIJXxT-eevBDQuW_0im6u3rw04ZJjB0MobFb0yhVYc31NjOUFoMN/s1600-h/aspnet_eventos_controles_usuario.PNG&#39;&gt;&lt;img border=&#39;0&#39; alt=&#39;&#39; src=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNEimd9_rVOsWkN44lKq9Q-kGNd5W3e3bkNj7FR4bpimY-4Q3J2rHh4RKIP-wag26Y7-ef5aQ14ALGFh0lrz6dFbd_EIJXxT-eevBDQuW_0im6u3rw04ZJjB0MobFb0yhVYc31NjOUFoMN/s320/aspnet_eventos_controles_usuario.PNG&#39;/&gt;&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;La generación del evento se realiza desde el code-behind:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;#region&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt; Eventos del control&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;public event&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;&lt;br /&gt;											&lt;span style=&#39;color:#2b91af&#39;&gt;EventHandler&lt;/span&gt; AceptarClicked;&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;protected&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;&lt;br /&gt;											&lt;span style=&#39;color:blue&#39;&gt;virtual&lt;/span&gt;&lt;br /&gt;											&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; OnClick(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender)&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (&lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.AceptarClicked != &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.AceptarClicked(sender, &lt;span style=&#39;color:blue&#39;&gt;new &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;EventArgs&lt;/span&gt;());&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;}&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;}&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:blue; font-family:Courier New; font-size:10pt&#39;&gt;#endregion&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Este código declara el evento (cuyo nombre será AceptarClicked) e implementa el método que invoca el evento.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;#region&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt; Propiedades publicas&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;private&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;&lt;br /&gt;											&lt;span style=&#39;color:#2b91af&#39;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt;&amp;gt; resultados;&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;public &lt;/span&gt;&lt;span style=&#39;color:#2b91af; font-family:Courier New&#39;&gt;List&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;&amp;lt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt;&amp;gt; Resultados&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;{&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;get&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt; { &lt;span style=&#39;color:blue&#39;&gt;return&lt;/span&gt; resultados; }&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;set&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt; { resultados = &lt;span style=&#39;color:blue&#39;&gt;value&lt;/span&gt;; }&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;}&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:blue; font-family:Courier New; font-size:10pt&#39;&gt;#endregion&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;El código anterior declara una propiedad pública dentro del control donde se almacenarán los resultados de la búsqueda.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;En el evento del botón del control de usuario realizamos la llamada al evento público que será capturado por la página:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;protected&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;&lt;br /&gt;											&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; btnBuscar_Click(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender, &lt;span style=&#39;color:#2b91af&#39;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;{&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New&#39;&gt;//Hardcode para simular una búsqueda&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.resultados = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt;&amp;gt;();&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;if&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt; (&lt;span style=&#39;color:#2b91af&#39;&gt;String&lt;/span&gt;.IsNullOrEmpty(&lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.txtPalabraClave.Text))&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;{&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.resultados.Add(&lt;span style=&#39;color:#a31515&#39;&gt;&quot;No se han encontrado resultados&quot;&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;}&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;else&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;{&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.resultados.Add(&lt;span style=&#39;color:#a31515&#39;&gt;&quot;Resultado1 para &quot;&lt;/span&gt; + &lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.txtPalabraClave.Text);&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.resultados.Add(&lt;span style=&#39;color:#a31515&#39;&gt;&quot;Resultado2 para &quot;&lt;/span&gt; + &lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.txtPalabraClave.Text);&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.resultados.Add(&lt;span style=&#39;color:#a31515&#39;&gt;&quot;Resultado3 para &quot;&lt;/span&gt; + &lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.txtPalabraClave.Text);&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.resultados.Add(&lt;span style=&#39;color:#a31515&#39;&gt;&quot;Resultado4 para &quot;&lt;/span&gt; + &lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.txtPalabraClave.Text);&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;}&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New&#39;&gt;//Se invoca el evento público una vez la función del control ha terminado&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;OnClick(sender);&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;La página debe capturar el evento, esto se hace de igual forma que se captura el evento de un botón o cualquier control de .NET. Así, en la presentación de la página tendremos:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;uc1&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;Buscador &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Buscador1&quot;&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;OnAceptarClicked&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Buscador1_AceptarClicked&quot;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Así el método de tratar el evento del control de usuario, dentro de la página padre será Buscador1_AceptarClicked y se codificará así:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;protected&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;&lt;br /&gt;											&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; Buscador1_AceptarClicked(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender, &lt;span style=&#39;color:#2b91af&#39;&gt;EventArgs&lt;/span&gt; e)&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;{&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;if&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt; (&lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.Buscador1.Resultados != &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;)&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;{&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.GridView1.DataSource = &lt;span style=&#39;color:blue&#39;&gt;this&lt;/span&gt;.Buscador1.Resultados;&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New&#39;&gt;this&lt;/span&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;.GridView1.DataBind();&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;&lt;span style=&#39;font-family:Courier New&#39;&gt;}&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;El código completo del ejemplo lo puedes encontrar &lt;a href=&#39;http://usercontrolevents.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=38016&#39;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Y esto es todo, espero que te sirva&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/1468665034798491173/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/aspnet-eventos-de-controles-de-usuarios.html#comment-form' title='8 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/1468665034798491173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/1468665034798491173'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/aspnet-eventos-de-controles-de-usuarios.html' title='ASP.NET - Eventos de Controles de Usuario (ASCX)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNEimd9_rVOsWkN44lKq9Q-kGNd5W3e3bkNj7FR4bpimY-4Q3J2rHh4RKIP-wag26Y7-ef5aQ14ALGFh0lrz6dFbd_EIJXxT-eevBDQuW_0im6u3rw04ZJjB0MobFb0yhVYc31NjOUFoMN/s72-c/aspnet_eventos_controles_usuario.PNG" height="72" width="72"/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-6469952949207960567</id><published>2009-12-31T02:58:00.001+01:00</published><updated>2010-01-02T16:50:22.521+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="ascx"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="control de usuario"/><title type='text'>ASCX - Creación de Controles de Usuario</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;Una buena práctica, y en mi opinión necesaria para cualquier desarrollo Web, es plantearse qué secciones de las páginas de la aplicación se mostrarán en varias páginas. Estas secciones serán susceptibles de desarrollarse como controles de usuario (&lt;a href=&#39;http://msdn.microsoft.com/en-us/library/y6wb1a0e(VS.85).aspx&#39;&gt;User Controls .NET&lt;/a&gt;).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Así, podríamos definir (a alto nivel) un control de usuario como una sección de una página que se repite en varias páginas. El hecho de crear un control de usuario nos evitará hacer Copy-Paste (tanto de la parte de presentación como del codebehind del control) de esta sección a lo largo de toda nuestra aplicación, además, a la hora de cambiar algo dentro de esta sección de la página, esta se encuentra en un solo punto y no en varias páginas de nuestra solución.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Para añadir un control de usuario a nuestra sitio Web, botón derecho sobre nuestro proyecto -&amp;gt; Agregar Nuevo Elemento &amp;gt; Control de Usuario Web.&lt;br /&gt;&lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;En función del número de controles de usuario que preveamos que vamos a precisar convendrá pensar si debemos distribuirlos en carpetas dentro de nuestra solución. Yo normalmente creo una carpeta de &quot;Controles&quot; dentro de mi solución, donde voy almacenando mis controles de usuario.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Bien, ya tenemos nuestro control de usuario en nuestra solución, &lt;a href=&#39;http://autenticacionform.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37996&#39;&gt;aquí&lt;/a&gt; puedes encontrar el ejemplo de una aplicación en que utilizo un control de usuario y será en esta solución en la que me base de aquí en adelante (en esta solución no he creado ninguna carpeta de controles ya que sólo tengo un control). Este control se corresponde con el menú de mi aplicación y, por tanto, se encontrará en todas las páginas y por ello está incluido en la página master de la solución. El código de mi ascx es el siguiente: &lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;background-color:yellow&#39;&gt;&amp;lt;%&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;@ &lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;Control &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;Language&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;C#&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;AutoEventWireup&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;true&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;CodeBehind&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;LoginControl.ascx.cs&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;Inherits&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;AutenticacionFormulario.LoginControl&quot; &lt;/span&gt;&lt;span style=&#39;background-color:yellow&#39;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;HyperLink &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;HyperLink1&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;Text&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Inicio&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;NavigateUrl&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;~/Default.aspx&quot; /&amp;gt;&lt;/span&gt; | &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;HyperLink &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;HyperLink2&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;Text&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Administracion&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;NavigateUrl&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;~/Admin/Admin.aspx&quot; /&amp;gt;&lt;/span&gt; | &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;HyperLink &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;HyperLink3&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;Text&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Usuario&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;NavigateUrl&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;~/User/User.aspx&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt; | &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;HyperLink &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;hyp1&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;Text&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Pagina segura&quot; &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;NavigateUrl&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;~/Secure/Administracion.aspx&quot;/&amp;gt;&lt;/span&gt; | &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoginView &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;lv1&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;AnonymousTemplate&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;Bienvenido, invitado&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;AnonymousTemplate&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoggedInTemplate&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;Bienvenido &lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoginName&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;ln1&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ForeColor&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;Green&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;Font-Bold&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;true&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt;,&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoggedInTemplate&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoginView&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;asp&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoginStatus&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;id&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;ls1&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;Cómo puedes ver un Control de Usuario se codifica exactamente igual que una página ASPX.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Para utilizar un Control de Usuario en una de tus páginas únicamente tendrás que arrastrarlo desde el &quot;Explorador de Soluciones&quot; hasta la página (esta debe estar abierta y en modo diseño). Esta acción generará lo siguiente en la página donde incluyes el control de usuario: &lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;- Registro del control de usuario dentro de la página:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;background-color:yellow&#39;&gt;&amp;lt;%&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;@ &lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;Register&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;src&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;LoginControl.ascx&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;tagname&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;LoginControl&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;tagprefix&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;uc1&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;background-color:yellow&#39;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;- Inclusión del control de usuario en la página: &lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:580px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr style=&#39;height: 2px&#39;&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 6px; padding-bottom: 1px; padding-right: 6px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;uc1&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;:&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;LoginControl&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;ID&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;LoginControl1&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;runat&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;server&quot;&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;Esto es todo no olvides pensar en crear controles de usuario, te facilitarán tanto el desarrollo como el mantenimiento de tus aplicaciones.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/6469952949207960567/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/ascx-creacion-de-controles-de-usuario.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/6469952949207960567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/6469952949207960567'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/ascx-creacion-de-controles-de-usuario.html' title='ASCX - Creación de Controles de Usuario'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-6650740750161107419</id><published>2009-12-31T01:45:00.001+01:00</published><updated>2009-12-31T01:48:38.746+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css"/><title type='text'>CSS - Cambiar la imagen del cursor</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;Esto no tiene que ver con .NET pero me ha surgido la duda de cómo hacerlo mientras navegaba por la web.&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Aunque en mi opinión el ratón es la herramienta fundamental del internauta y por tanto no conviene cambiar su imagen, el cambio de la imagen del cursor puede causar en el usuario una impresión de novedad.&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Es muy sencillo, sólo tenemos que añadir el siguiente código a nuestra página o a nuestra hoja de estilos CSS:&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;br /&gt;				&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:581px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 7px; padding-bottom: 1px; padding-right: 7px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;style&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:red&#39;&gt;type&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&quot;text/css&quot;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#a31515&#39;&gt;body&lt;/span&gt;, &lt;span style=&#39;color:#a31515&#39;&gt;a&lt;/span&gt;, &lt;span style=&#39;color:#a31515&#39;&gt;a:hover&lt;/span&gt;&lt;br /&gt;									&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;span style=&#39;color:red&#39;&gt;cursor&lt;/span&gt;: &lt;span style=&#39;color:blue&#39;&gt;url(http://cur.cursors-4u.net/anime/ani-10/ani973.ani),&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;progress&lt;/span&gt;;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;style&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;En esta &lt;a href=&#39;http://www.cursors-4u.com&#39;&gt;página&lt;/a&gt; puedes encontrar muchos cursores.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/6650740750161107419/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/css-cambiar-la-imagen-del-cursor.html#comment-form' title='1 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/6650740750161107419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/6650740750161107419'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/css-cambiar-la-imagen-del-cursor.html' title='CSS - Cambiar la imagen del cursor'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-6220359656879778198</id><published>2009-12-30T20:01:00.001+01:00</published><updated>2010-01-02T14:19:29.485+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="autenticacion"/><category scheme="http://www.blogger.com/atom/ns#" term="formulario"/><category scheme="http://www.blogger.com/atom/ns#" term="roles"/><category scheme="http://www.blogger.com/atom/ns#" term="seguridad"/><title type='text'>ASP.NET Autenticación por Formulario (Parte II)</title><content type='html'>&lt;span xmlns=&#39;&#39;&gt;&lt;p&gt;Puedes descargarte el ejemplo completo &lt;a href=&#39;http://autenticacionform.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37996&#39;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;En este post voy a explicar cómo manejar los roles de los usuarios con una autenticación basada en formularios.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;En mi anterior post &lt;a href=&#39;http://csharp-experience.blogspot.com/2009/12/aspnet-autenticacion-por-formulario.html&#39;&gt;ASP.NET Autenticación por Formulario (Parte I)&lt;/a&gt; explico cómo crear una aplicación cuya seguridad está basada en la autenticación por formulario, con una sección de administración. El paso siguiente dentro de la seguridad de un sitio Web es aplicar significado a los roles de usuario, para ello vamos a crear diferentes regiones seguras dentro de la aplicación en las que el usuario tendrá acceso en función de sus roles asignados. En esta ocasión la autenticación se realiza contra una base de datos, a la cual accedemos mediante queries LINQ (ya explicaré cómo utilizar LINQ para el acceso a datos en un próximo post).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Voy a partir de la solución de mi anterior post que puedes descargar &lt;a href=&#39;http://autenticacionform.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37864&#39;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;He seguido lo siguientes pasos:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;1.- He añadido una base de datos a mi solución una base de datos&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Botón derecho sobre el proyecto - &amp;gt;Agregar &amp;gt; Nuevo elemento.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Se selecciona &quot;Base de Datos SQL Server&quot;.&lt;br /&gt;&lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;br/&gt;&lt;a href=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNfZpCQA4dQrf71GoFdEjc_GrO7lgA4PLB6GFNqX6XnfOlBde-uQ315Q8oEY3CFqyBKZzm1yzgqJeTO0QLjPmtszPgc2hMXiVi_kWVs9HiyGz6UY_kQ4a96FqFAOuCY8UWO-RCvshKmu3i/s1600-h/aspnet_autenticacion_formulario2.PNG&#39;&gt;&lt;img border=&#39;0&#39; alt=&#39;&#39; src=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNfZpCQA4dQrf71GoFdEjc_GrO7lgA4PLB6GFNqX6XnfOlBde-uQ315Q8oEY3CFqyBKZzm1yzgqJeTO0QLjPmtszPgc2hMXiVi_kWVs9HiyGz6UY_kQ4a96FqFAOuCY8UWO-RCvshKmu3i/s320/aspnet_autenticacion_formulario2.PNG&#39;/&gt;&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;2.- He creado las siguientes tablas&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- USUARIO: Contiene todos los usuarios registrados en nuestro sistema. Tiene los siguientes campos: ID_USUARIO, LOGIN, PASSWORD&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- ROLE: Que contendrá todos los roles que necesita nuestra aplicación. Tiene los campos: ID_ROLE, DESCRIPCION.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- ROLES_USUARIO: Mantiene la relación n:m entre los usuarios y sus roles, permitiendo que un usuario pueda tener varios roles.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;En el ejemplo que os presento existen dos roles (admin y user) y dos usuarios, así el usuario administrador tendrá todos los roles para poder acceder a todas las secciones de la aplicación.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;3.- He agregado un Diagrama de Clases LINQ to SQL&lt;/span&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Botón derecho sobre el proyecto -&amp;gt; Agregar &amp;gt; Nuevo elemento.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Se selecciona &quot;Clases de LINQ to SQL&quot;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;- Se rellena diagrama de clases LINQ (simplemente arrastrando la tabla desde el &quot;Explorador de Servidores&quot; hasta el diagrama de clases. Además he añadido las asociaciones entre las tablas obteniendo el resultado siguiente:&lt;br /&gt;&lt;/p&gt;&lt;p style=&#39;text-align: center&#39;&gt;&lt;a href=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjskNZwHMxbXghieJMRruWvJR-n9LvfYEvwVltHNCUJeiqtIEsjwcwXqzWBVEJ89nnNo8mrNk3skGYF05zSnzCxTfh7ZK7clVm-Q7myzm6nngWjUYzR8H1Ym4hPcqxsL49iB8nR5rqtl7Lc/s1600-h/aspnet_autenticacion_formulario2c.PNG&#39;&gt;&lt;img border=&#39;0&#39; alt=&#39;&#39; src=&#39;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjskNZwHMxbXghieJMRruWvJR-n9LvfYEvwVltHNCUJeiqtIEsjwcwXqzWBVEJ89nnNo8mrNk3skGYF05zSnzCxTfh7ZK7clVm-Q7myzm6nngWjUYzR8H1Ym4hPcqxsL49iB8nR5rqtl7Lc/s320/aspnet_autenticacion_formulario2c.PNG&#39;/&gt;&lt;/a&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;Se generarán así una serie de clases que nos permiten el acceso a la base de datos de una forma transparente, además de auto configurarse un ConnectionString.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;4.- Creación de clases ADO para el acceso a los datos&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- He creado dos clases, Rol y Usuario:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;La clase Rol está implementada así:&lt;br /&gt;&lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:581px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 7px; padding-bottom: 1px; padding-right: 7px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;public class&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:#2b91af&#39;&gt;Rol&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;AutenticacionDataClassesDataContext&lt;/span&gt; dc = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt; AutenticacionDataClassesDataContext&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;const&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;char&lt;/span&gt; SI = &lt;span style=&#39;color:#a31515&#39;&gt;&#39;S&#39;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal void&lt;/span&gt; AddRole (&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; description)&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt; role = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;role.DESCRIPCION = description;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;dc.ROLE.InsertOnSubmit(role);&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;dc.SubmitChanges();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt; FindRol(&lt;span style=&#39;color:#2b91af&#39;&gt;Guid&lt;/span&gt;? codigoRole)&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;var&lt;/span&gt; roles = &lt;span style=&#39;color:blue&#39;&gt;from&lt;/span&gt; u &lt;span style=&#39;color:blue&#39;&gt;in&lt;/span&gt; dc.ROLE&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;where&lt;/span&gt; u.ID_ROLE == codigoRole&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;select&lt;/span&gt; u;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (roles.Count() &amp;gt; 0)&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return&lt;/span&gt; roles.First();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New; font-size:10pt&#39;&gt;else&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return null&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;La clase Usuario tiene el siguiente código:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:581px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 7px; padding-bottom: 1px; padding-right: 7px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;public&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;class&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:#2b91af&#39;&gt;Usuario&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;AutenticacionDataClassesDataContext&lt;/span&gt; dc = &lt;span style=&#39;color:blue&#39;&gt;new &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;AutenticacionDataClassesDataContext&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;const char&lt;/span&gt; SI = &lt;span style=&#39;color:#a31515&#39;&gt;&#39;S&#39;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal void&lt;/span&gt; AddUsuario(&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; login, &lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; password)&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;USUARIO&lt;/span&gt; usuario = &lt;span style=&#39;color:blue&#39;&gt;new &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;USUARIO&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;usuario.LOGIN = login; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;usuario.PASSWORD = password; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;dc.USUARIO.InsertOnSubmit(usuario); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;dc.SubmitChanges();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt; &lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;USUARIO&lt;/span&gt; FindUsuario(&lt;span style=&#39;color:#2b91af&#39;&gt;Guid&lt;/span&gt; codigoUsuario) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;var&lt;/span&gt; usu = &lt;span style=&#39;color:blue&#39;&gt;from&lt;/span&gt; u &lt;span style=&#39;color:blue&#39;&gt;in&lt;/span&gt; dc.USUARIO&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;where&lt;/span&gt; u.ID_USUARIO == codigoUsuario&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;select&lt;/span&gt; u; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (usu.Count() &amp;gt; 0) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return&lt;/span&gt; usu.First();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New; font-size:10pt&#39;&gt;else&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return null&lt;/span&gt;; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:#2b91af&#39;&gt;USUARIO&lt;/span&gt; FindUsuario(&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; login, &lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; password) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;var&lt;/span&gt; usu = &lt;span style=&#39;color:blue&#39;&gt;from&lt;/span&gt; u &lt;span style=&#39;color:blue&#39;&gt;in&lt;/span&gt; dc.USUARIO&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;where&lt;/span&gt; (u.LOGIN == login &amp;amp;&amp;amp; u.PASSWORD == password) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;select&lt;/span&gt; u; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (usu.Count() &amp;gt; 0) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return&lt;/span&gt; usu.First();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;color:blue; font-family:Courier New; font-size:10pt&#39;&gt;else&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return null&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal void&lt;/span&gt; AddRole(&lt;span style=&#39;color:#2b91af&#39;&gt;Guid&lt;/span&gt; idUsuario, &lt;span style=&#39;color:#2b91af&#39;&gt;Guid&lt;/span&gt; idRole)&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLES_USUARIO&lt;/span&gt; rolesUsuario = &lt;span style=&#39;color:blue&#39;&gt;new &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLES_USUARIO&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;rolesUsuario.ID_ROLE = idRole;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;rolesUsuario.ID_USUARIO = idUsuario;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;dc.ROLES_USUARIO.InsertOnSubmit(rolesUsuario);&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;dc.SubmitChanges();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;internal &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt;&amp;gt; FindRolesUsuario(&lt;span style=&#39;color:#2b91af&#39;&gt;Guid&lt;/span&gt;? codigoUsuario) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt;&amp;gt; listRole = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt;&amp;gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;var&lt;/span&gt; roles = &lt;span style=&#39;color:blue&#39;&gt;from&lt;/span&gt; u &lt;span style=&#39;color:blue&#39;&gt;in&lt;/span&gt; dc.ROLES_USUARIO&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;where&lt;/span&gt; u.ID_USUARIO == codigoUsuario&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;select&lt;/span&gt; u; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (roles.Count() &amp;gt; 0) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLES_USUARIO&lt;/span&gt;&amp;gt; rolesUsuario = roles.AsEnumerable&amp;lt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLES_USUARIO&lt;/span&gt;&amp;gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;foreach&lt;/span&gt; (&lt;span style=&#39;color:#2b91af&#39;&gt;ROLES_USUARIO&lt;/span&gt; roleUusario &lt;span style=&#39;color:blue&#39;&gt;in&lt;/span&gt; rolesUsuario) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;Rol&lt;/span&gt; rolADO = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;br/&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;Rol&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt; rol = rolADO.FindRol(roleUusario.ID_ROLE); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (rol != &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 180pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;listRole.Add(rol); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;return&lt;/span&gt; listRole; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;He implementado algunos métodos que no necesitaré en esta versión, no prestéis especial atención a como están implementados, no creo que sirvan de referencia como uso de LINQ :D.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;5.- Implementación de la autenticación de usuarios&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;Bien, una vez que tenemos listo nuestras clases de acceso a datos con los métodos que vamos a precisar para recuperar los usuarios y sus roles, podemos pasar a implementar la autenticación de los usuarios. He implementado el evento de autenticación de la siguiente forma:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:581px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 7px; padding-bottom: 1px; padding-right: 7px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;protected&lt;/span&gt;&lt;br /&gt;										&lt;span style=&#39;color:blue&#39;&gt;void&lt;/span&gt; Login1_Authenticate(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender, &lt;span style=&#39;color:#2b91af&#39;&gt;AuthenticateEventArgs&lt;/span&gt; e) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; userName = Login1.UserName; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; password = Login1.Password; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;bool&lt;/span&gt; rememberUserName = Login1.RememberMeSet; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;Usuario&lt;/span&gt; usuarioADO = &lt;span style=&#39;color:blue&#39;&gt;new &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;Usuario&lt;/span&gt;();&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;USUARIO&lt;/span&gt; usuario = usuarioADO.FindUsuario(userName, password); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (usuario != &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;List&lt;/span&gt;&amp;lt;&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt;&amp;gt; roles = usuarioADO.FindRolesUsuario(usuario.ID_USUARIO); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (roles != &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; rolesData = &lt;span style=&#39;color:#a31515&#39;&gt;&quot;&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;foreach&lt;/span&gt; (&lt;span style=&#39;color:#2b91af&#39;&gt;ROLE&lt;/span&gt; role &lt;span style=&#39;color:blue&#39;&gt;in&lt;/span&gt; roles) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;rolesData += role.DESCRIPCION.ToString() + &lt;span style=&#39;color:#a31515&#39;&gt;&quot;;&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se crea el ticket de autenticación&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;FormsAuthenticationTicket&lt;/span&gt; ticket = &lt;span style=&#39;color:blue&#39;&gt;new &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;FormsAuthenticationTicket&lt;/span&gt;(&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;1, &lt;span style=&#39;color:green&#39;&gt;// Versión del ticket&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;userName,&lt;span style=&#39;color:green&#39;&gt;// Nombre de usuario asociado al ticket&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;DateTime&lt;/span&gt;.Now, &lt;span style=&#39;color:green&#39;&gt;// Fecha de creación del ticket&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;DateTime&lt;/span&gt;.Now.AddMinutes(50), &lt;span style=&#39;color:green&#39;&gt;// Fecha y Hora de las expiración de la cookie&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;rememberUserName, &lt;span style=&#39;color:green&#39;&gt;// Si el usuario cliquó en &quot;Recuérdame&quot; la cookie no expira.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;rolesData, &lt;span style=&#39;color:green&#39;&gt;// Almacena datos del usuario, en este caso los roles&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;FormsAuthentication&lt;/span&gt;.FormsCookiePath); &lt;span style=&#39;color:green&#39;&gt;// El path de la cookie especificado en el Web.Config&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se encripta la cookie para añadir más seguridad&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; hashCookies = &lt;span style=&#39;color:#2b91af&#39;&gt;FormsAuthentication&lt;/span&gt;.Encrypt(ticket); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Cookie encriptada&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;HttpCookie&lt;/span&gt; cookie = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt; HttpCookie&lt;/span&gt;(&lt;span style=&#39;color:#2b91af&#39;&gt;FormsAuthentication&lt;/span&gt;.FormsCookieName, hashCookies); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se añade la cookie a la respuesta&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;Response.Cookies.Add(cookie); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se recupera la url que el usuario trataba de acceder&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt; returnUrl = Request.QueryString[&lt;span style=&#39;color:#a31515&#39;&gt;&quot;ReturnUrl&quot;&lt;/span&gt;];&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// si no existe dicha url redirigimos al usuario a la pagina por defecto&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (returnUrl == &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;) returnUrl = &lt;span style=&#39;color:#a31515&#39;&gt;&quot;~/Default.aspx&quot;&lt;/span&gt;;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;Response.Redirect(returnUrl); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;else &lt;/span&gt;&lt;span style=&#39;color:green&#39;&gt;// usuario y password erróneos&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// no se hace nada, el control Login mostrará automáticament los errores&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;Este código autentica a los usuarios contra nuestra base de datos y añade los roles del usuario.&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;6.- Creamos los directorios seguros en función de los roles&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Creamos los siguientes directorios:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;- Admin: Destinado únicamente para usuarios administradores (usuarios con el rol &#39;admin&#39;).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- User: Destinado a los usuarios del sitio (con el rol &#39;user&#39;). P.e: Este directorio podría contener las páginas donde el usuario gestiona su propia cuenta&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Se securizan estos directorios modificando el Web.config de la siguiente forma:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:581px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 7px; padding-bottom: 1px; padding-right: 7px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;location &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;path&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;Admin&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;system.web&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;authorization&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;allow &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;roles&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;admin&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;deny &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;users&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;*&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt; /&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;authorization&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;system.web&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;location&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;location &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;path&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;User&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;system.web&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;authorization&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;allow &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;roles&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;user&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;deny &lt;/span&gt;&lt;span style=&#39;color:red&#39;&gt;users&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;=&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;*&lt;/span&gt;&quot;&lt;span style=&#39;color:blue&#39;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;authorization&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;system.web&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&#39;color:#a31515&#39;&gt;location&lt;/span&gt;&lt;span style=&#39;color:blue&#39;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&#39;color:white&#39;&gt;7.- Creamos control de usuario&lt;/span&gt;:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Este control de usuario se añade para poder hacer pruebas de nuestra autenticación y se añade a la página master de nuestra aplicación (Ah! Sí también creé una página master para que este control de usuario esté disponible en todas las páginas de nuestro sitio).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;span style=&#39;color:white&#39;&gt;8.- Modificamos el fichero Global.asax (si no existiese lo agregaríamos)&lt;/span&gt;&lt;br /&gt;			&lt;/p&gt;&lt;p&gt;En este fichero se añade la gestión de la autenticación de un usuario, en el siguiente código:&lt;br /&gt;&lt;/p&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table border=&#39;0&#39; style=&#39;border-collapse:collapse; background: white&#39;&gt;&lt;colgroup&gt;&lt;col style=&#39;width:581px&#39;/&gt;&lt;/colgroup&gt;&lt;tbody valign=&#39;top&#39;&gt;&lt;tr&gt;&lt;td style=&#39;padding-top: 1px; padding-left: 7px; padding-bottom: 1px; padding-right: 7px; border-top:  dashed 0.5pt; border-left:  dashed 0.5pt; border-bottom:  dashed 0.5pt; border-right:  dashed 0.5pt&#39; vAlign=&#39;middle&#39;&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;protected void&lt;/span&gt; Application_AuthenticateRequest(&lt;span style=&#39;color:blue&#39;&gt;object&lt;/span&gt; sender, &lt;span style=&#39;color:#2b91af&#39;&gt;EventArgs&lt;/span&gt; e) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Si se envía alguna información acerca del usuario&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (&lt;span style=&#39;color:#2b91af&#39;&gt;HttpContext&lt;/span&gt;.Current.User != &lt;span style=&#39;color:blue&#39;&gt;null&lt;/span&gt;) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// se comprueba que el usuario esté autenticado&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (&lt;span style=&#39;color:#2b91af&#39;&gt;HttpContext&lt;/span&gt;.Current.User.Identity.IsAuthenticated) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se comprueba si el usuario está autenticado por formulario&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;if&lt;/span&gt; (&lt;span style=&#39;color:#2b91af&#39;&gt;HttpContext&lt;/span&gt;.Current.User.Identity &lt;span style=&#39;color:blue&#39;&gt;is &lt;/span&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;FormsIdentity&lt;/span&gt;) &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;{&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se recupera la identidad del usuario para recuperar sus roles&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;FormsIdentity&lt;/span&gt; identity = (&lt;span style=&#39;color:#2b91af&#39;&gt;FormsIdentity&lt;/span&gt;)&lt;span style=&#39;color:#2b91af&#39;&gt;HttpContext&lt;/span&gt;.Current.User.Identity; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se recupera el ticket del usuario&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;FormsAuthenticationTicket&lt;/span&gt; ticket = identity.Ticket; &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se recupera la información acerca del usuario, donde metimos la información de los roles&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:blue&#39;&gt;string&lt;/span&gt;[] roles = ticket.UserData.Split(&lt;span style=&#39;color:#a31515&#39;&gt;&#39;;&#39;&lt;/span&gt;); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;color:green; font-family:Courier New; font-size:10pt&#39;&gt;// Se crea un usuario con dichos roles&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 144pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;&lt;span style=&#39;color:#2b91af&#39;&gt;HttpContext&lt;/span&gt;.Current.User = &lt;span style=&#39;color:blue&#39;&gt;new&lt;/span&gt; System.Security.Principal.&lt;span style=&#39;color:#2b91af&#39;&gt;GenericPrincipal&lt;/span&gt;(identity, roles); &lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 108pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 72pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p style=&#39;margin-left: 36pt&#39;&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;br /&gt;								&lt;/p&gt;&lt;p&gt;&lt;span style=&#39;font-family:Courier New; font-size:10pt&#39;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; &lt;br /&gt; &lt;/p&gt;&lt;p&gt;¡Y esto es todo!&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Puedes descargarte el ejemplo completo &lt;a href=&#39;http://autenticacionform.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37996&#39;&gt;aquí&lt;/a&gt;.&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/6220359656879778198/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/aspnet-autenticacion-por-formulario_30.html#comment-form' title='19 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/6220359656879778198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/6220359656879778198'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/aspnet-autenticacion-por-formulario_30.html' title='ASP.NET Autenticación por Formulario (Parte II)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNfZpCQA4dQrf71GoFdEjc_GrO7lgA4PLB6GFNqX6XnfOlBde-uQ315Q8oEY3CFqyBKZzm1yzgqJeTO0QLjPmtszPgc2hMXiVi_kWVs9HiyGz6UY_kQ4a96FqFAOuCY8UWO-RCvshKmu3i/s72-c/aspnet_autenticacion_formulario2.PNG" height="72" width="72"/><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-557902786835022368.post-2128226675436728818</id><published>2009-12-28T12:33:00.000+01:00</published><updated>2009-12-29T05:00:57.370+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".net"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="autenticacion"/><category scheme="http://www.blogger.com/atom/ns#" term="formulario"/><category scheme="http://www.blogger.com/atom/ns#" term="seguridad"/><title type='text'>ASP.NET Autenticación por Formulario (Parte I)</title><content type='html'>&lt;span xmlns=&quot;&quot;&gt;&lt;p&gt;Puedes descargar el código &lt;a href=&quot;http://autenticacionform.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37864&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;En este post voy a explicar cómo crear una aplicación Web en la que existirá una sección segura. La autenticación vía formulario se suele utilizar para securizar el acceso a una determinada página (o grupo de páginas) a usuario no autenticados.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Las páginas a las que deseas restringir el acceso pueden ser las páginas de administración de tu sitio Web. Sigue los pasos siguientes:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:white;&quot;&gt;Paso 1 - Creación de página de login:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;- Crea un nuevo proyecto desde Visual Studio (Sitio Web o Aplicación Web)&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Añade una página &quot;Login.aspx&quot;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Agrega un control asp:login a la página &quot;Login.aspx&quot;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p style=&quot;TEXT-ALIGN: center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvEQjn235u4lb9nhca7tW2FTgCNBBieNywRfTdI-1m86QEbatCFukBZdM4QvSeL8gmsJuS3_etuOQusWwyh_P8ouR0gSemZuPcVtLxTgQC198ErYi9X1fpQSAB4-QnDax1Te_vdFDuV5w/s1600-h/aspnet_autenticacion_formulario1.PNG&quot;&gt;&lt;img alt=&quot;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvEQjn235u4lb9nhca7tW2FTgCNBBieNywRfTdI-1m86QEbatCFukBZdM4QvSeL8gmsJuS3_etuOQusWwyh_P8ouR0gSemZuPcVtLxTgQC198ErYi9X1fpQSAB4-QnDax1Te_vdFDuV5w/s320/aspnet_autenticacion_formulario1.PNG&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;TEXT-ALIGN: center&quot;&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;- Implementación del evento Authenticate del control de Login.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table style=&quot;BACKGROUND: white; BORDER-COLLAPSE: collapse&quot; border=&quot;0&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;WIDTH: 573px&quot;&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;&lt;tr&gt;&lt;td style=&quot;BORDER-RIGHT: 0.5pt dashed; PADDING-RIGHT: 7px; BORDER-TOP: 0.5pt dashed; PADDING-LEFT: 7px; PADDING-BOTTOM: 1px; BORDER-LEFT: 0.5pt dashed; PADDING-TOP: 1px; BORDER-BOTTOM: 0.5pt dashed&quot; valign=&quot;center&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;protected&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:blue;&quot;&gt;void&lt;/span&gt; Login1_Authenticate(&lt;span style=&quot;color:blue;&quot;&gt;object&lt;/span&gt; sender, &lt;span style=&quot;color:#2b91af;&quot;&gt;AuthenticateEventArgs&lt;/span&gt; e)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;bool&lt;/span&gt; authenticated = AuthenticateMe(Login1.UserName, Login1.Password, Login1.RememberMeSet);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color:blue;&quot;&gt;if&lt;/span&gt; (authenticated)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color:#2b91af;&quot;&gt;FormsAuthentication&lt;/span&gt;.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;private&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:blue;&quot;&gt;bool&lt;/span&gt; AuthenticateMe(&lt;span style=&quot;color:blue;&quot;&gt;string&lt;/span&gt; userName, &lt;span style=&quot;color:blue;&quot;&gt;string&lt;/span&gt; password, &lt;span style=&quot;color:blue;&quot;&gt;bool&lt;/span&gt; rememberUserName)&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;{&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;color:green;&quot;&gt;//Se trata de un hardcode, en un caso real la validación se hará contra una base de datos&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;string&lt;/span&gt; localUserName = &lt;span style=&quot;color:#a31515;&quot;&gt;&quot;admin&quot;&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;string&lt;/span&gt; localPassword = &lt;span style=&quot;color:#a31515;&quot;&gt;&quot;1234&quot;&lt;/span&gt;;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;if&lt;/span&gt; (userName.Equals(localUserName) &amp;amp;&amp;amp; password.Equals(localPassword))&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;{&lt;span style=&quot;color:blue;&quot;&gt;return true&lt;/span&gt;;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;else&lt;/span&gt;{&lt;span style=&quot;color:blue;&quot;&gt;return false&lt;/span&gt;;}&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:9;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:white;&quot;&gt;Paso 2 - Modificación del Web.config:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;- En este paso se modifica el Web.config para indicar la url por defecto del sitio (&lt;strong&gt;defaultUrl&lt;/strong&gt;), la url de la página de login (&lt;strong&gt;loginUrl&lt;/strong&gt;), se indica si la sesión segura espira (&lt;strong&gt;slidingExpiration&lt;/strong&gt;) y el &lt;strong&gt;timeout&lt;/strong&gt; en minutos.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table style=&quot;BACKGROUND: white; BORDER-COLLAPSE: collapse&quot; border=&quot;0&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;WIDTH: 581px&quot;&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;&lt;tr&gt;&lt;td style=&quot;BORDER-RIGHT: 0.5pt dashed; PADDING-RIGHT: 7px; BORDER-TOP: 0.5pt dashed; PADDING-LEFT: 7px; PADDING-BOTTOM: 1px; BORDER-LEFT: 0.5pt dashed; PADDING-TOP: 1px; BORDER-BOTTOM: 0.5pt dashed&quot; valign=&quot;center&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;authentication&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;mode&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;Forms&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;forms&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;defaultUrl&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;default.aspx&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;loginUrl&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;~/login.aspx&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;slidingExpiration&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;true&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;timeout&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;20&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;forms&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;authentication&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;authorization&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;authorization&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:white;&quot;&gt;Paso 3 - Creación de un directorio seguro:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Dentro de este directorio se encontrarán aquellas páginas cuyo acceso se quiere restringir.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Crea una nueva carpeta dentro de tu proyecto (p.e: Secure).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Dentro de este directorio añade una página (p.e: Administracion.aspx).&lt;br /&gt;&lt;/p&gt;&lt;p&gt;- Añade un Web.config dentro de esta carpeta e incluye el siguiente contenido en el mismo.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;div&gt;&lt;table style=&quot;BACKGROUND: white; BORDER-COLLAPSE: collapse&quot; border=&quot;0&quot;&gt;&lt;colgroup&gt;&lt;col style=&quot;WIDTH: 581px&quot;&gt;&lt;/colgroup&gt;&lt;tbody valign=&quot;top&quot;&gt;&lt;tr&gt;&lt;td style=&quot;BORDER-RIGHT: 0.5pt dashed; PADDING-RIGHT: 7px; BORDER-TOP: 0.5pt dashed; PADDING-LEFT: 7px; PADDING-BOTTOM: 1px; BORDER-LEFT: 0.5pt dashed; PADDING-TOP: 1px; BORDER-BOTTOM: 0.5pt dashed&quot; valign=&quot;center&quot;&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;?&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;xml &lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;version&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;1.0&lt;/span&gt;&quot; &lt;span style=&quot;color:red;&quot;&gt;encoding&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;utf-8&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;?&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;appSettings&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;connectionStrings&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 72pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;authorization&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 108pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;deny &lt;/span&gt;&lt;span style=&quot;color:red;&quot;&gt;users&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;=&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;?&lt;/span&gt;&quot;&lt;span style=&quot;color:blue;&quot;&gt;/&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 72pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;authorization&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;MARGIN-LEFT: 36pt&quot;&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;system.web&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-family:Courier New;font-size:10;&quot;&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:#a31515;&quot;&gt;configuration&lt;/span&gt;&lt;span style=&quot;color:blue;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt; &lt;/p&gt;&lt;p&gt;&lt;span style=&quot;color:white;&quot;&gt;Paso 4 - Ejecuta tu aplicación:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Selecciona la página Administracion.aspx como página de inicio y pulsa F5. Serás redireccionado a la página de Login, una vez hayas introducido las credenciales correctas, la página de login re redireccionará hasta la página de Administracion.aspx&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Puedes descargar el código &lt;a href=&quot;http://autenticacionform.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=37864&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://csharp-experience.blogspot.com/feeds/2128226675436728818/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/aspnet-autenticacion-por-formulario.html#comment-form' title='5 comentarios'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/2128226675436728818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/557902786835022368/posts/default/2128226675436728818'/><link rel='alternate' type='text/html' href='http://csharp-experience.blogspot.com/2009/12/aspnet-autenticacion-por-formulario.html' title='ASP.NET Autenticación por Formulario (Parte I)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05161700664581625365</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvEQjn235u4lb9nhca7tW2FTgCNBBieNywRfTdI-1m86QEbatCFukBZdM4QvSeL8gmsJuS3_etuOQusWwyh_P8ouR0gSemZuPcVtLxTgQC198ErYi9X1fpQSAB4-QnDax1Te_vdFDuV5w/s72-c/aspnet_autenticacion_formulario1.PNG" height="72" width="72"/><thr:total>5</thr:total></entry></feed>