<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Manas &#187; Sergio Medina</title>
	<atom:link href="http://www.manas.com.ar/smedina/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.manas.com.ar</link>
	<description>Thinking code</description>
	<lastBuildDate>Tue, 07 Feb 2012 19:55:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Windows Day: El futuro de la plataforma de desarrollo web hoy</title>
		<link>http://www.manas.com.ar/smedina/2009/03/03/windows-day/</link>
		<comments>http://www.manas.com.ar/smedina/2009/03/03/windows-day/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 14:42:39 +0000</pubDate>
		<dc:creator>Sergio Medina</dc:creator>
				<category><![CDATA[Blogs]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.manas.com.ar/smedina/?p=12</guid>
		<description><![CDATA[[English version below] En el d&#237;a de hoy Microsoft lanz&#243; Windows Day, un evento online en donde todos los desarrolladores y profesionales IT interesados podr&#225;n asistir a charlas y demostraciones de las tecnolog&#237;as que hoy en d&#237;a se estan utilizando y de las que vendr&#225;n. Brian y yo tuvimos la oportunidad de participar en una &#8230; <a href="http://www.manas.com.ar/smedina/2009/03/03/windows-day/">more</a>]]></description>
			<content:encoded><![CDATA[<p align="center"><strong>[English version below]</strong></p>
<p align="center"><a href="http://www.manas.com.ar/smedina/wp-content/uploads/2009/03/imageaxd1.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="306" alt="image.axd" src="http://www.manas.com.ar/smedina/wp-content/uploads/2009/03/imageaxd-thumb1.jpg" width="389" border="0" /></a> </p>
<p align="left">En el d&#237;a de hoy Microsoft lanz&#243; <strong><a href="http://www.microsoft.com/latam/windowsday/">Windows Day</a></strong>, un evento online en donde todos los desarrolladores y profesionales IT interesados podr&#225;n asistir a charlas y demostraciones de las tecnolog&#237;as que hoy en d&#237;a se estan utilizando y de las que vendr&#225;n.</p>
<p align="left"><a href="http://www.manas.com.ar/bcardiff/">Brian</a> y yo tuvimos la oportunidad de participar en una charla llamada &quot;<em><a href="http://200.58.118.10/post/Sesion-MSDN-2El-futuro-de-la-plataforma-de-desarrollo-Web-hoy.aspx">El futuro de la plataforma de desarrollo web hoy</a></em>&quot; en donde hablamos sobre las innovaciones de ASP.NET 4.0 entre otras cosas:</p>
<ul>
<li>
<div align="left">ASP.NET MVC</div>
</li>
<li>
<div align="left">Dynamic Data</div>
</li>
<li>
<div align="left">Client Templates</div>
</li>
<li>
<div align="left">IE 8 &amp; Developer Tools</div>
</li>
<li>
<div align="left">jQuery</div>
</li>
</ul>
<p>Pueden descargar aqu&#237; las <a href="http://www.manas.com.ar/smedina/wp-content/uploads/2009/03/el-futuro-de-la-plataforma-de-desarrollo-web-hoy1.pdf">diapositivas</a> y el c&#243;digo fuente de la demo de <a href="http://www.manas.com.ar/smedina/wp-content/uploads/2009/03/dynamicmarquee.zip">Dynamic Data</a>, y del blog de <a href="http://www.manas.com.ar/bcardiff/">Brian</a> el de <a href="http://www.manas.com.ar/bcardiff/2009/03/latam-windows-day-el-futuro-de-la-plataforma-de-desarrollo-web-hoy/">Client Templates</a>.</p>
<p>Espero que les guste, cr&#237;ticas y comentarios son siempre bienvenidos!</p>
<p><strong><font size="3">[English version]</font></strong></p>
<p>Today Microsoft launched <strong><a href="http://www.microsoft.com/latam/windowsday/">Windows Day</a></strong>, an online event where everyone involved with IT could take part in lectures and demos about the technologies developers are using right now, and some others which are coming.</p>
<p><a href="http://www.manas.com.ar/bcardiff/">Brian</a> and me had the opportunity to collaborate with a topic called &quot;<a href="http://200.58.118.10/post/Sesion-MSDN-2El-futuro-de-la-plataforma-de-desarrollo-Web-hoy.aspx"><em>The future of web development, today</em></a>&quot; where we talk about the new features in ASP.NET 4.0 and some other stuff:</p>
<ul>
<li>ASP.NET MVC </li>
<li>Dynamic Data </li>
<li>Client Templates </li>
<li>IE 8&#160; &amp; Developer Tools </li>
<li>jQuery </li>
</ul>
<p>You can download here the <a href="http://www.manas.com.ar/smedina/wp-content/uploads/2009/03/el-futuro-de-la-plataforma-de-desarrollo-web-hoy1.pdf">slides</a> and the <a href="http://www.manas.com.ar/smedina/wp-content/uploads/2009/03/dynamicmarquee.zip">Dynamic Data demo source code</a>, and from <a href="http://www.manas.com.ar/bcardiff/">Brian&#8217;s blog</a> the <a href="http://www.manas.com.ar/bcardiff/2009/03/latam-windows-day-el-futuro-de-la-plataforma-de-desarrollo-web-hoy/">Client Templates source code</a>.</p>
<p>I hope you like it, critics and comments are always welcome!</p>
<div align="left">SERch.-</div>
<div align="left"></div>

]]></content:encoded>
			<wfw:commentRss>http://www.manas.com.ar/smedina/2009/03/03/windows-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internationalization in ASP.NET MVC</title>
		<link>http://www.manas.com.ar/smedina/2008/12/17/internationalization-in-aspnet-mvc/</link>
		<comments>http://www.manas.com.ar/smedina/2008/12/17/internationalization-in-aspnet-mvc/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 18:48:00 +0000</pubDate>
		<dc:creator>Sergio Medina</dc:creator>
				<category><![CDATA[Blogs]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Internationalization]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.manas.com.ar/smedina/?p=6</guid>
		<description><![CDATA[Anyone who is starting almost any kind of software nowadays should be thinking on internationalization, even more if it is web-based. The effort required to prepare a system for localization (the difference between internationalization and localization is subtle, you can find it on Wikipedia) from the very beginning is minimum and the payoff is huge. &#8230; <a href="http://www.manas.com.ar/smedina/2008/12/17/internationalization-in-aspnet-mvc/">more</a>]]></description>
			<content:encoded><![CDATA[<p>Anyone who is starting almost any kind of software nowadays should be thinking on internationalization, even more if it is web-based. The effort required to prepare a system for localization (the difference between internationalization and localization is subtle, you can find it on <a href="http://en.wikipedia.org/wiki/Internationalization_and_localization">Wikipedia</a>) from the very beginning is minimum and the payoff is huge.</p>
<p>In this post I will first describe in the large how we can approach this problem with ASP.NET MVC, and then I will provide some easy steps to accomplish the task.</p>
<p><strong>General idea of i18n</strong></p>
<p>We will start by setting all the strings that our system uses in a key-value pair file. We will have one of these files for each language we choose to support, for instance the values for the key “colors” would be “colors”, “colours” and “colores” in the files <em>Resources.en-US.resx</em>, <em>Resources.en-UK.resx</em> and <em>Resources.es.resx</em> respectively. After that we only have to know which file to pick, in order to do that we read the preferred language sent by the browser on every Http request. Finally we should give the user the option to change the language, imagine that an English speaker would not be very happy to check his e-mail with the browser preferred language during his vacations in China!</p>
<p><strong>1. Create the resources files</strong></p>
<p>The first thing we are going to do is to create the resources file/s. Right-click on the <em>App_GlobalResources</em> folder, add a new <em>resource file</em> and name it <em>Resources.resx</em>: this would be the <strong>default</strong> language. By adding this item, another file called <em>Resource.designer.cs</em> is added to the project, it provides direct access to the key-value pairs we define on the resource file/s. In this post we will show how to support English (default) and Spanish, so we add another resource file called <em>Resources.es.resx</em>. Finally we add some string to those files, for instance: “Welcome” associated with “Welcome to MySite!” and “Bienvenido/a a MiSitio!”.</p>
<p>When we access these string within the code the Framework first try to do an exact match with the language. For instance if the language is set to <em>es-AR</em> (Spanish from Argentina) the framework will look first for the more specific resource file (<em>Resources.es-AR.resx</em> in this case), if that file does not exist the one corresponding to the parent language would be chosen (<em>Resources.es.resx</em>) and if that is not found either, then the default resource file is used.</p>
<p><strong>2. Use the browser preferred language</strong></p>
<p>In ASP.NET MVC is very easy to set the current culture to the browser’s preference. We just need to add a single line to the <em>Web.config</em> file: after the <em>&lt;system.web&gt;</em> tag we add:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; height: 36px; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff">&lt;</span><span style="color: #800000">system.web</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">globalization</span> <span style="color: #ff0000">culture</span><span style="color: #0000ff">="auto"</span> <span style="color: #ff0000">uiCulture</span><span style="color: #0000ff">="auto"</span><span style="color: #0000ff">/&gt;</span></pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>Now we are ready to test what  we have done so far. We just need to change the access modifier of the default resource file from <em>internal</em> to <em>public</em>. Then every string defined on these files could be accessed by just writing:</p>
<pre class="code">App_GlobalResources.<span style="color: #2b91af">Resources</span>.Welcome;</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p><strong>3. Set the user preferred language and store it in a cookie</strong></p>
<p>We have two ways to do this: server-side or client-side. In my personal opinion, as we only need to create and store a cookie and reload the site, is not convenient to go to the server. On the other hand, doing this client-side could be a bit more difficult. Luckily, we have <strong><a href="http://jquery.com/">jQuery</a></strong>!</p>
<p>First we need to have some links or cute images associated with <em>onclick</em> events:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff">&lt;</span><span style="color: #800000">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">="#"</span> <span style="color: #ff0000">onclick</span><span style="color: #0000ff">="changeLang('es-AR')"</span><span style="color: #0000ff">&gt;</span>es-AR<span style="color: #0000ff">&lt;/</span><span style="color: #800000">a</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;</span><span style="color: #800000">a</span> <span style="color: #ff0000">href</span><span style="color: #0000ff">="#"</span> <span style="color: #ff0000">onclick</span><span style="color: #0000ff">="changeLang('en-US')"</span><span style="color: #0000ff">&gt;</span>en-US<span style="color: #0000ff">&lt;/</span><span style="color: #800000">a</span><span style="color: #0000ff">&gt;</span></pre>
</div>
<p>On the <em>&lt;head&gt;</em> section we need to import jQuery (line 1) and the cookie plugin (line 2), which can be found <a href="http://plugins.jquery.com/project/Cookie">here</a> and a nice demo <a href="http://stilbuero.de/jquery/cookie/">here</a>.</p>
<p> </p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<div style="font-size: 8pt; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   1:</span> &lt;script src=<span style="color: #006080">"/Scripts/jquery-1.2.6.js"</span> type=<span style="color: #006080">"text/javascript"</span>&gt;&lt;/script&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   2:</span> &lt;script src=<span style="color: #006080">"/Scripts/jquery.cookie.js"</span> type=<span style="color: #006080">"text/javascript"</span>&gt;&lt;/script&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   3:</span> &lt;script type=<span style="color: #006080">"text/javascript"</span>&gt;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">function</span> changeLang(lang) {</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   5:</span>         $.cookie(<span style="color: #006080">'lang'</span>, lang);</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   6:</span>         window.location.reload();</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   7:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>;</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   8:</span>     }</pre>
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #606060">   9:</span> &lt;/script&gt;</pre>
<p> </p></div>
</div>
<p>In line 5 the jQuery Cookie Plugin is used to store the chosen language in a variable named <em>‘lang’</em>, and the statement in line 6 tell the browser to reload the site. What for? We will see in the next (and final) step.</p>
<p><strong>4. Eat the cookie (before everybody else!)</strong></p>
<p>As we all know, every cookie which is associated with the current domain is sent with every Http request. It would be great if we could write some code to “catch” each request, see if there is a cookie with the preferred language, and set it.</p>
<p>ASP.NET works with Http Modules which, in short, are pieces of code that can play with the Http request before it reaches to the handlers. Mansoor Ahmed Siddiqui wrote a <a href="http://www.15seconds.com/Issue/020417.htm">great post</a> about this, which I strongly recommend.</p>
<p>First we register the module in the <em>Web.config</em> file, so the Framework knows it have to be executed with every request:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; height: 117px; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff">&lt;</span><span style="color: #800000">httpModules</span><span style="color: #0000ff">&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="ScriptModule"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span><span style="color: #0000ff">/&gt;</span>
    <span style="color: #008000">&lt;!-- this one is our module =) --&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="CookieLocalizationModule"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="MyProject.CookieLocalizationModule, MyProject"</span><span style="color: #0000ff">/&gt;</span>
    <span style="color: #0000ff">&lt;</span><span style="color: #800000">add</span> <span style="color: #ff0000">name</span><span style="color: #0000ff">="UrlRoutingModule"</span> <span style="color: #ff0000">type</span><span style="color: #0000ff">="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"</span><span style="color: #0000ff">/&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">httpModules</span><span style="color: #0000ff">&gt;</span></pre>
</div>
<p>Finally the code, which is pretty what you can image: getting the cookie and setting the language, with some more lines the modules require:</p>
<div style="font-size: 8pt; margin: 20px 0px 10px; overflow: auto; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border: gray 1px solid; padding: 4px;">
<pre style="font-size: 8pt; margin: 0em; overflow: visible; width: 100%; color: black; line-height: 12pt; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4; border-style: none; padding: 0px;"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> CookieLocalizationModule : IHttpModule
{
    <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Dispose()
    {
    }

    <span style="color: #0000ff">public</span> <span style="color: #0000ff">void</span> Init(HttpApplication context)
    {
        context.BeginRequest += <span style="color: #0000ff">new</span> EventHandler(context_BeginRequest);
    }

    <span style="color: #0000ff">void</span> context_BeginRequest(<span style="color: #0000ff">object</span> sender, EventArgs e)
    {
        <span style="color: #008000">// eat the cookie (if any) and set the culture</span>
        <span style="color: #0000ff">if</span> (HttpContext.Current.Request.Cookies[<span style="color: #006080">"lang"</span>] != <span style="color: #0000ff">null</span>)
        {
            HttpCookie cookie = HttpContext.Current.Request.Cookies[<span style="color: #006080">"lang"</span>];
            <span style="color: #0000ff">string</span> lang = cookie.Value;
            var culture = <span style="color: #0000ff">new</span> System.Globalization.CultureInfo(lang);
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
        }
    }
}</pre>
</div>
<p><strong>And that is all?</strong></p>
<p>Almost. There is one more thing we need to do: internationalize images. Although it is quite an easy task and there are many ways of doing it, this post is long enough so I will write about it later.</p>
<p>This should be enough for lots of applications and many languages. However there exists some issues related with Arabic languages (which are written from right to left) and some Asian ones (which use symbols) that are not at all cover in this post.</p>
<p>Thanks a lot <a href="http://www.manas.com.ar/bcardiff/">Brian</a> for all the help!<br />
I hope this have been useful. Have a nice day!<br />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manas.com.ar/smedina/2008/12/17/internationalization-in-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Adding e-mail verification on ASP.NET MVC using Membership Framework.</title>
		<link>http://www.manas.com.ar/smedina/2008/11/28/adding-e-mail-verification-on-aspnet-mvc-using-membership-framework/</link>
		<comments>http://www.manas.com.ar/smedina/2008/11/28/adding-e-mail-verification-on-aspnet-mvc-using-membership-framework/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 19:51:00 +0000</pubDate>
		<dc:creator>Sergio Medina</dc:creator>
				<category><![CDATA[Blogs]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.manas.com.ar/smedina/?p=5</guid>
		<description><![CDATA[Since last week I have been learning and working with ASP.NET MVC Beta. I found a lot of interesting and easy-to-use things which convinced me that it is a good choice for web development. The Membership Framework is one of those. Unfortunately a more-than-common feature like user e-mail verification is not built-in so I had &#8230; <a href="http://www.manas.com.ar/smedina/2008/11/28/adding-e-mail-verification-on-aspnet-mvc-using-membership-framework/">more</a>]]></description>
			<content:encoded><![CDATA[<p>Since last week I have been learning and working with ASP.NET MVC Beta. I found a lot of interesting and easy-to-use things which convinced me that it is a good choice for web development. The Membership Framework is one of those.</p>
<p>Unfortunately a more-than-common feature like user e-mail verification is not built-in so I had to do it myself. Here are the three easy steps you should follow in order to add this functionality to your site:</p>
<p><strong>Store the user as unapproved</strong> </p>
<p>We create the new user as usual, except for the value isApproved which we should set to false. This indicates that the user is on the database but is inactive and cannot log in (until we verify his or her e-mail).</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 300px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; height: 258px; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">// Attempt to register the user</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> MembershipCreateStatus createStatus;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   3:</span> MembershipUser newUser = Provider.CreateUser(username, password, email, pwQuestion, pwAnswer, <span style="color: #0000ff">false</span>, <span style="color: #0000ff">null</span>, <span style="color: #0000ff">out</span> createStatus);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   5:</span> <span style="color: #0000ff">if</span> (newUser != <span style="color: #0000ff">null</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #008000">// The user was created successfully, we send the verification e-mail.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     SendVerificationMail(newUser);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   9:</span>     <span style="color: #0000ff">return</span> Content(<span style="color: #006080">&quot;Your account have been created. Please check your e-mail to activate it.&quot;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  11:</span> <span style="color: #0000ff">else</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  13:</span>     <span style="color: #008000">// There were errors, show them to the user.</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     ModelState.AddModelError(<span style="color: #006080">&quot;_FORM&quot;</span>, ErrorCodeToString(createStatus));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  15:</span> }</pre>
</p></div>
</div>
<p><strong>Prepare the verification e-mail</strong></p>
<p>The most important thing in this part is to provide the user with a link to verify his or her account. The link must be difficult for anyone to create. In this example we will use the <em>global unique identifier</em> or <em>guid</em> which is a good trade-off between security and code simplicity. For more information about GUIDs you can check <a href="http://msdn.microsoft.com/en-us/library/system.guid.aspx">MSDN</a>. We will see a way to enhance security later.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 500px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; height: 354px; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> SendVerificationMail(MembershipUser user)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   3:</span>     MailMessage email = <span style="color: #0000ff">new</span> MailMessage(</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         <span style="color: #006080">&quot;info@yourSite.com&quot;</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   5:</span>         user.Email</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     );</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   7:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     Guid guid = (Guid)user.ProviderUserKey;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   9:</span>     email.Subject = <span style="color: #006080">&quot;Welcome!&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     email.Body = <span style="color: #006080">&quot;Activation link: yourSite/controller/action/&quot;</span> + guid.ToString();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  11:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>     SmtpClient smtp = <span style="color: #0000ff">new</span> SmtpClient(<span style="color: #006080">&quot;your_smtp&quot;</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  13:</span>     smtp.Credentials = CredentialCache.DefaultNetworkCredentials;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  15:</span>     <span style="color: #0000ff">try</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>        smtp.Send(email);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  17:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>     <span style="color: #0000ff">catch</span> (Exception exc){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  19:</span>         <span style="color: #008000">// Handle exception</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  21:</span> }</pre>
</p></div>
</div>
<p>Note that the link points to some controller and action we have not defined yet. We can use an existing controller (maybe the AccounController) or a new one. We might also use a different URL routing, though I decided to keep the default for simplicity.</p>
<p><strong>Verifying the link</strong></p>
<p>One more step and we are ready to go live! Now we should receive the request and verify that the GUID is the right one. If everything is OK we approve the user.</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 400px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; height: 262px; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> ActionResult Verify(<span style="color: #0000ff">string</span> id)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   3:</span>     Guid guid = <span style="color: #0000ff">new</span> Guid(id);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     MembershipUser user = Membership.GetUser(guid);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #0000ff">if</span> (user != <span style="color: #0000ff">null</span> &amp;&amp; user.IsApproved == <span style="color: #0000ff">false</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   7:</span>         user.IsApproved = <span style="color: #0000ff">true</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         Membership.UpdateUser(user);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   9:</span>         FormsAuth.SetAuthCookie(user.UserName, <span style="color: #0000ff">false</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">else</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         <span style="color: #008000">// Wrong GUID or user was already approved</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  13:</span>     }    </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  15:</span>     <span style="color: #0000ff">return</span> View();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span> }</pre>
</p></div>
</div>
<p>And that’s all! Quite an interesting feature in very few and easy steps.</p>
<p><strong>Enhancing security</strong></p>
<p>Though using a Global Unique Identifier provides a quite secure environment sometimes Security is such an important matter that we should think in adding some more complications to those good hackers out there <img src='http://www.manas.com.ar/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> .<br />
  <br />A good option would be adding another parameter to the action, like an MD5 hash applied to the email or username, or a combination. Useful help is, again, on <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx">MSDN</a>.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.manas.com.ar/smedina/2008/11/28/adding-e-mail-verification-on-aspnet-mvc-using-membership-framework/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why I started a blog?</title>
		<link>http://www.manas.com.ar/smedina/2008/11/28/why-i-started-a-blog/</link>
		<comments>http://www.manas.com.ar/smedina/2008/11/28/why-i-started-a-blog/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 12:36:20 +0000</pubDate>
		<dc:creator>Sergio Medina</dc:creator>
				<category><![CDATA[Blogs]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.manas.com.ar/smedina/?p=3</guid>
		<description><![CDATA[Many times I have faced problems during my day-to-day tasks. Always, the first attemp to solve them is surfing the web. Sometimes I find help on official sites, sometimes I end up asking a friend, but many times the best help is on some blog round there. Then I thought I could add my little &#8230; <a href="http://www.manas.com.ar/smedina/2008/11/28/why-i-started-a-blog/">more</a>]]></description>
			<content:encoded><![CDATA[<p>Many times I have faced problems during my day-to-day tasks. Always, the first attemp to solve them is surfing the web. Sometimes I find help on official sites, sometimes I end up asking a friend, but many times the best help is on some blog round there. Then I thought I could add my little piece of contribution to this little big word of IT and that is what this blog would (try) to be.</p>
<p>I hope that my experiences (both good and bad ones!) would be found useful for some of you. And if not, at least have fun!</p>
<p>SERch.-<br />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.manas.com.ar/smedina/2008/11/28/why-i-started-a-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

