<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Diviforum.net</title>
	
	<link>http://diviforum.net</link>
	<description>Estudos e tecnologias da plataforma .NET</description>
	<lastBuildDate>Sat, 21 Jan 2012 17:15:50 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Diviforumnet" /><feedburner:info uri="diviforumnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Diviforumnet</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Windows Phone: por onde começar</title>
		<link>http://feedproxy.google.com/~r/Diviforumnet/~3/JEcD7QgGKbY/</link>
		<comments>http://diviforum.net/2011/windows-phone-onde-comecar/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 15:47:28 +0000</pubDate>
		<dc:creator>Guilherme Gomes</dc:creator>
				<category><![CDATA[Windows Phone]]></category>
		<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[onde comecar]]></category>
		<category><![CDATA[windows phone]]></category>

		<guid isPermaLink="false">http://diviforum.net/?p=144</guid>
		<description><![CDATA[A Microsoft sempre teve uma presença no mercado mobile, mas eu sempre tive comigo que ela jamais deu a devida importância a ele até o surgimento do iPhone e sua mágica App Store. E agora a Microsoft tem sua presença em peso com o Windows Phone. E claro nenhum smartphone não sobrevive sem um ecossistema [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://diviforum.net/wp-content/uploads/2011/12/wp-phone.png"><img class="alignleft size-thumbnail wp-image-145" title="wp-phone" src="http://diviforum.net/wp-content/uploads/2011/12/wp-phone-150x150.png" alt="" width="150" height="150" /></a>A Microsoft sempre teve uma presença no mercado mobile, mas eu sempre tive comigo que ela jamais deu a devida importância a ele até o surgimento do iPhone e sua mágica App Store.</p>
<p>E agora a Microsoft tem sua presença em peso com o Windows Phone. E claro nenhum smartphone não sobrevive sem um ecossistema a sua volta com aplicativos de terceiros. E ele tem o <a href="http://www.windowsphone.com/pt-BR/marketplace" target="_blank">Market Place</a>.</p>
<p>Pelo que eu vi a maior vantagem que dará mercado ao Windows Phone é a forma como ele está sendo integrado a outros ecossistemas, como o desktop, a sala de estar (alô XBox 360), escritório (MS Office, skype etc). E isso é um grande diferencial, afinal todos estamos acostumados a usar o nosso Windows de cada dia.</p>
<p>Você deve estar animado com toda essa perspectiva e quer saber por onde começar, bem vamos lá.</p>
<p>O que é necessário instalar:</p>
<ul>
<li>Visual Studio ou a versão express (Vs for Windows Phone).</li>
<li><a href="http://www.microsoft.com/download/en/details.aspx?id=13890" target="_blank">SDK do WP7</a></li>
</ul>
<p>Referências para ler:</p>
<ul>
<li>MSDN (<a href="http://msdn.microsoft.com/pt-br/hh230679" target="_blank">centro de desenvolvimento</a>).</li>
<li><a href="http://windowsphonebrasil.com.br/" target="_blank">Windows Phone Brasil</a>.</li>
<li>MSDN (<a href="http://msdn.microsoft.com/pt-br/windowsphone" target="_blank">centro de treinamento</a>).</li>
</ul>
<p>Se alguém souber de outras referências, deixem aí nos comentários.</p>
<img src="http://feeds.feedburner.com/~r/Diviforumnet/~4/JEcD7QgGKbY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://diviforum.net/2011/windows-phone-onde-comecar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://diviforum.net/2011/windows-phone-onde-comecar/</feedburner:origLink></item>
		<item>
		<title>MD5: Validando um arquivo com C#</title>
		<link>http://feedproxy.google.com/~r/Diviforumnet/~3/GPpmLZlg4Fw/</link>
		<comments>http://diviforum.net/2011/md5-validando-um-arquivo-com-c-sharp/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 12:02:14 +0000</pubDate>
		<dc:creator>Guilherme Gomes</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[validacao]]></category>

		<guid isPermaLink="false">http://diviforum.net/?p=133</guid>
		<description><![CDATA[MD5 hoje é uma das tecnologias de criptografia mais utilizadas, vários sites para atestarem a validade de um arquivo disponibilizando a hash do mesmo. A grande vantagem é que ao verificar esta string é que você tem a garantia que tem uma cópia igual a do servidor em que você baixou. Existem (creio eu) que [...]]]></description>
			<content:encoded><![CDATA[<p>MD5 hoje é uma das tecnologias de criptografia mais utilizadas, vários sites para atestarem a validade de um arquivo disponibilizando a hash do mesmo. A grande vantagem é que ao verificar esta string é que você tem a garantia que tem uma cópia igual a do servidor em que você baixou.</p>
<p>Existem (creio eu) que existem mil e uma formas de se validar um arquivo com md5, aqui vou utilizar c# para validar um arquivo qualquer.</p>
<p>Inicialmente eu crie um form com 2 abas bem simples:</p>
<p style="text-align: center;"><a href="http://diviforum.net/wp-content/uploads/2011/12/form-gerar.png"><img class="aligncenter size-full wp-image-129" title="form-gerar.png" src="http://diviforum.net/wp-content/uploads/2011/12/form-gerar.png" alt="" width="435" height="253" /></a><br />
Imagem 1-1</p>
<p style="text-align: center;"><a href="http://diviforum.net/wp-content/uploads/2011/12/form-validar.png"><img class="aligncenter size-full wp-image-131" title="form-validar.png" src="http://diviforum.net/wp-content/uploads/2011/12/form-validar.png" alt="" width="440" height="261" /></a><br />
Imagem 1-2</p>
<p>Na imagem 1-2 o zero é apenas para identificar a existência de um label. Não vou mostrar no post os códigos para fazer os forms funcionarem, mas postarei o projeto com o mesmo funcionando, pois acho que este não é o escopo do post.</p>
<p>Feito isso vamos a parte prática do código para validar/gerar:</p>
<p>Para verificar um md5:</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060;">   1:</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Boolean VerificaMD5(FileStream arquivo, String Md5)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060;">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060;">   3:</span>         Boolean retorno = <span style="color: #0000ff;">false</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060;">   4:</span>         MD5 x = <span style="color: #0000ff;">new</span> MD5CryptoServiceProvider();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060;">   5:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060;">   6:</span>         <span style="color: #0000ff;">byte</span>[] retval = x.ComputeHash(arquivo);</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060;">   7:</span>         arquivo.Close();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060;">   8:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum9" style="color: #606060;">   9:</span>         StringBuilder rt = <span style="color: #0000ff;">new</span> StringBuilder();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum10" style="color: #606060;">  10:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum11" style="color: #606060;">  11:</span>         <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 0; i &lt; retval.Length; i++)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum12" style="color: #606060;">  12:</span>         {</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum13" style="color: #606060;">  13:</span>             rt.Append(retval[i].ToString(<span style="color: #006080;">"X2"</span>));</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum14" style="color: #606060;">  14:</span>         }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum15" style="color: #606060;">  15:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum16" style="color: #606060;">  16:</span>         <span style="color: #0000ff;">if</span> (rt.ToString().Equals(Md5))</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum17" style="color: #606060;">  17:</span>             retorno = <span style="color: #0000ff;">true</span>;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum18" style="color: #606060;">  18:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum19" style="color: #606060;">  19:</span>         <span style="color: #0000ff;">return</span> retorno;</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum20" style="color: #606060;">  20:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum21" style="color: #606060;">  21:</span> }</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Codigo 1-1</p>
<p>&nbsp;</p>
<div id="codeSnippetWrapper">
<div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum1" style="color: #606060;">   1:</span> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> String GerarMd5(FileStream arquivo)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum2" style="color: #606060;">   2:</span>     {</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum3" style="color: #606060;">   3:</span>             MD5 x = <span style="color: #0000ff;">new</span> MD5CryptoServiceProvider();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum4" style="color: #606060;">   4:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum5" style="color: #606060;">   5:</span>             <span style="color: #0000ff;">byte</span>[] retval = x.ComputeHash(arquivo);</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum6" style="color: #606060;">   6:</span>             arquivo.Close();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum7" style="color: #606060;">   7:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum8" style="color: #606060;">   8:</span>             StringBuilder rt = <span style="color: #0000ff;">new</span> StringBuilder();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum9" style="color: #606060;">   9:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum10" style="color: #606060;">  10:</span>             <span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">int</span> i = 0; i &lt; retval.Length; i++)</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum11" style="color: #606060;">  11:</span>             {</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum12" style="color: #606060;">  12:</span>                 rt.Append(retval[i].ToString(<span style="color: #006080;">"X2"</span>));</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum13" style="color: #606060;">  13:</span>             }</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum14" style="color: #606060;">  14:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum15" style="color: #606060;">  15:</span>             <span style="color: #0000ff;">return</span> rt.ToString();</pre>
<p><!--CRLF--></p>
<pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span id="lnum16" style="color: #606060;">  16:</span> }</pre>
<p><!--CRLF--></p>
</div>
</div>
<p>Codigo 1-2</p>
<p>No código 1-1, é recebido uma String e o FileStream do arquivo a ser verificado, criado o provider do Md5, chamo o método ComputeHash(FileStream) que retorna um vetor de bytes.<br />
Com o StringBuilder vou adicionando e armazenando os valores.<br />
ao final verifico se a String recebida é igual a gerada e dou um retorno boolean<br />
No código 1-2 para gerar segue a mesma lógica do 1-1 com a diferença que como estou gerando basta retornar a String com o valor md5.</p>
<p>Esta lógica pode ser aplicada em qualquer contexto bastando uma adaptação para o que for necessário validar, vale a pena consultar nas referências no fim do post para saber mais sobre a classe MD5CryptoServiceProvider</p>
<p>&nbsp;</p>
<h3>Referências:</h3>
<ul>
<li><a href="http://msdn.microsoft.com/pt-br/library/system.security.cryptography.md5cryptoserviceprovider.aspx">MD5CryptoServiceProvider</a></li>
<li><a href="http://msdn.microsoft.com/pt-br/library/2839d5h5.aspx">StringBuilder</a></li>
</ul>
<h3>Download do projeto:</h3>
<p><a  title='Projeto Verifica Md5' href='http://diviforum.net/?wpdmact=process&did=My5ob3RsaW5r' style="background:url('http://diviforum.net/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;">Download</a></p>
<p>Hash do arquivo do projeto: E950DD87A178ECF9DDD8752E0E0598A5</p>
<img src="http://feeds.feedburner.com/~r/Diviforumnet/~4/GPpmLZlg4Fw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://diviforum.net/2011/md5-validando-um-arquivo-com-c-sharp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://diviforum.net/2011/md5-validando-um-arquivo-com-c-sharp/</feedburner:origLink></item>
		<item>
		<title>ASP.NET MVC – Iniciando – Controller</title>
		<link>http://feedproxy.google.com/~r/Diviforumnet/~3/hK7iEA1FN50/</link>
		<comments>http://diviforum.net/2011/controller-aspnet-mvc/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 17:28:17 +0000</pubDate>
		<dc:creator>Vitor A. Vale</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Tutoriais]]></category>

		<guid isPermaLink="false">http://diviforum.net/?p=110</guid>
		<description><![CDATA[Este artigo é uma continuação do artigo: ASP.NET MVC – Iniciando – Primeiro Projeto Normalmente a arquitetura MVC apresenta os controller’s como manipuladores de requisições de entrada, no entanto o ASP.NET MVC os compreende simplesmente como classes que geralmente herdam as características da classe base dos controladores (System.Web.Mvc.Controller), você pode estudar mais a fundo a [...]]]></description>
			<content:encoded><![CDATA[<p>Este artigo é uma continuação do artigo:</p>
<ul>
<li><a title="ASP.NET MVC - Iniciando - Primeiro Projeto" href="http://diviforum.net/2011/introducao-aspnet-mvc/" target="_blank">ASP.NET MVC – Iniciando – Primeiro Projeto</a></li>
</ul>
<p>Normalmente a arquitetura MVC apresenta os controller’s como manipuladores de requisições de entrada, no entanto o ASP.NET MVC os compreende simplesmente como classes que geralmente herdam as características da classe base dos controladores (System.Web.Mvc.Controller), você pode estudar mais a fundo a classe na biblioteca da MSDN no artigo “<a title="Classe Controller - MSDN" href="http://msdn.microsoft.com/pt-br/library/system.web.mvc.controller.aspx" target="_blank">Classe Controller</a>”.</p>
<p>Por convenção os controller’s são armazenados em uma pasta chamada Controllers, o Visual Studio já criou esta pasta durante a criação do projeto, como é demonstrado pela Figura 1-1.</p>
<p><a title="Figura 1-1. Pasta de armazenamento dos Controller’s" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-1.jpg" target="_blank"><img class="alignnone size-full wp-image-111" title="Controller - Parte 1 - ASP.NET MVC - Figura 1-1" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-1.jpg" alt="Controller - Parte 1 - ASP.NET MVC - Figura 1-1" width="265" height="169" /></a><br />
Figura 1-1. Pasta de armazenamento dos Controller’s</p>
<p>Cada método público contido em um controller é visto como um método de ação, permitindo que ele seja invocado por meio de alguma solicitação web pela URL para executar uma determinada ação.</p>
<p>Para adicionar um novo controller em seu projeto, clique com o botão direito do mouse sobre a pasta Controllers no Solution Explorer e escolha Adicionar -&gt; Controller&#8230; como demonstrado na Figura 1-2.</p>
<p><a title="Figura 1-2. Adicionando um novo controller no projeto" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-2.jpg" target="_blank"><img class="alignnone size-medium wp-image-112" title="Controller - Parte 1 - ASP.NET MVC - Figura 1-2" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-2-300x109.jpg" alt="Controller - Parte 1 - ASP.NET MVC - Figura 1-2" width="300" height="109" /></a><br />
Figura 1-2. Adicionando um novo controller no projeto</p>
<p>Uma caixa de diálogo semelhante à apresentada na Figura 1-3 deverá aparecer, defina o nome como HomeController, como não é o intuito desta tutorial detalhar Scaffolding deixe a opção Empty controller selecionada e clique no botão.</p>
<p><a title="Figura 1-3. Adicionando as configurações do novo controller" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-3.jpg" target="_blank"><img class="alignnone size-medium wp-image-113" title="Controller - Parte 1 - ASP.NET MVC - Figura 1-3" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-3-300x195.jpg" alt="Controller - Parte 1 - ASP.NET MVC - Figura 1-3" width="300" height="195" /></a><br />
Figura 1-3. Adicionando as configurações do novo controller</p>
<p>A prática de adicionar seus Controller’s na pasta Controllers, e renomeá-los com o sufixo Controller são convenções da arquitetura do MVC, não é preciso que você siga estas ou a maioria das demais convenções, mas recomendo que durante o acompanhamento do tutorial o faça, pois isto ajudará num melhor entendimento do que está sendo demonstrado.</p>
<p>Como pode ser visualizado na Figura 1-4 o Visual Studio criou um novo arquivo chamado HomeController.cs com uma classe de mesmo nome herdando da classe Controller.</p>
<p><a title="Figura 1-4. Controller recém-criado" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-4.jpg" target="_blank"><img class="alignnone size-medium wp-image-114" title="Controller - Parte 1 - ASP.NET MVC - Figura 1-4" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-4-300x167.jpg" alt="Controller - Parte 1 - ASP.NET MVC - Figura 1-4" width="300" height="167" /></a><br />
Figura 1-4. Controller recém-criado</p>
<p>Para modificar o código gerado abra sua classe HomeController.cs para edição (duplo clique sobre ela no Solution Explorer) e altere o código para ficar semelhante ao apresentado na Listagem 1-1, as partes que necessitam ser alteradas estão destacadas em negrito.</p>
<p>Listagem 1-1. Modificando o controlador</p>
<pre class="brush: csharp; html-script: true">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DfTutorial01.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/

public <span style="text-decoration: underline;"><strong>String</strong></span> Index()
{
return <span style="text-decoration: underline;"><strong>"Olá mundo!!! (do meu controller) (:"</strong></span>;
}

}
}</pre>
<p>Neste ponto ainda não criamos nada muito grande, as alterações realizadas foram simples, alteramos o tipo de retorno do método Index para String e colocamos um texto para ser retornado. Execute a aplicação (F5), o navegador irá exibir o resultado do método Index() do HomeController semelhante ao demonstrado na Figura 1-5.</p>
<p><a title="Figura 1-5. Retorno da ação do método Index()" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-5.jpg" target="_blank"><img class="alignnone size-medium wp-image-115" title="Controller - Parte 1 - ASP.NET MVC - Figura 1-5" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_parte2_mvc_1-5-300x112.jpg" alt="Controller - Parte 1 - ASP.NET MVC - Figura 1-5" width="300" height="112" /></a><br />
Figura 1-5. Retorno da ação do método Index()</p>
<p>Código Fonte: <a  title='ASP.NET MVC – Controller -  Código Fonte' href='http://diviforum.net/?wpdmact=process&did=Mi5ob3RsaW5r' style="background:url('http://diviforum.net/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;">Download</a></p>
<img src="http://feeds.feedburner.com/~r/Diviforumnet/~4/hK7iEA1FN50" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://diviforum.net/2011/controller-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://diviforum.net/2011/controller-aspnet-mvc/</feedburner:origLink></item>
		<item>
		<title>ASP.NET MVC – Iniciando – Primeiro Projeto</title>
		<link>http://feedproxy.google.com/~r/Diviforumnet/~3/_1ONE7R66_Y/</link>
		<comments>http://diviforum.net/2011/introducao-aspnet-mvc/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 11:21:56 +0000</pubDate>
		<dc:creator>Vitor A. Vale</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Desenvolvimento]]></category>
		<category><![CDATA[Tutoriais]]></category>

		<guid isPermaLink="false">http://diviforum.net/?p=90</guid>
		<description><![CDATA[A melhor maneira de APRENDER uma nova TECNOLOGIA de desenvolvimento de software é pular de cabeça nela. Nesta série de artigos do @diviforum você criará um aplicativo de entrada de dados simples utilizando o ASP.NET MVC Framework. Tentando manter as coisas simples a construção deste aplicativo será dividida entre alguns posts para dar um passo de [...]]]></description>
			<content:encoded><![CDATA[<p>A melhor maneira de APRENDER uma nova TECNOLOGIA de desenvolvimento de software é pular de cabeça nela. Nesta série de artigos do @diviforum você criará um aplicativo de entrada de dados simples utilizando o ASP.NET MVC Framework.</p>
<p>Tentando manter as coisas simples a construção deste aplicativo será dividida entre alguns posts para dar um passo de cada vez para que você possa ver como uma aplicação ASP.NET MVC é construída.</p>
<p>Este tutorial não visa demonstrar o processo de instalação e configuração do ASP.NET MVC e os demais recursos necessários em seu ambiente de desenvolvimento, para prosseguir é necessário que você possua os seguintes itens instalados em seu sistema:</p>
<ul>
<li>Microsoft Visual Studio ou Visual Web Developer 2010 Express</li>
<li>ASP.NET 4 e ASP.NET MVC 3</li>
<li>Microsoft .NET Framework 4.0</li>
</ul>
<p>Caso ainda não possua estes recursos em seu sistema utilize a Microsoft Web PI (Web Platform Installer) 3.0, através deste link: (WPI) <a title="Microsoft Web Olatform Installer" href="http://www.microsoft.com/web/downloads/platform.aspx" target="_blank">http://www.microsoft.com/web/downloads/platform.aspx</a></p>
<p><strong>CRIANDO UM NOVO PROJETO ASP.NET MVC</strong></p>
<p>Vamos começar criando um novo projeto MVC no VS (Visual Studio), selecione um novo projeto no menu arquivo &gt; novo ( File -&gt; New -&gt; Project), como mostrado na Figura 1-1.</p>
<p><a title="Figura 1-1. Criando um novo projeto no Visual Studio" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-1.jpg" target="_blank"><img class="alignnone size-medium wp-image-91" title="Introdução ao ASP.NET MVC - Figura 1-1" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-1-300x86.jpg" alt="Introdução ao ASP.NET MVC - Figura 1-1" width="300" height="86" /></a><br />
Figura 1-1. Criando um novo projeto no Visual Studio</p>
<p>Se sua instalação do ASP.NET MVC 3 ocorreu com sucesso você encontrará entre os modelos Web um item chamado ASP.NET MVC Web Application 3, como mostrado na Figura 1-2.</p>
<p><a title="Figura 1-2. Visual Studio MVC 3 modelo de projeto" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-2.jpg" target="_blank"><img class="alignnone size-medium wp-image-92" title="Introdução ao ASP.NET MVC - Figura 1-2" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-2-300x98.jpg" alt="Introdução ao ASP.NET MVC - Figura 1-2" width="300" height="98" /></a><br />
Figura 1-2. Visual Studio MVC 3 modelo de projeto</p>
<p>Adicione um nome (Name) para o novo projeto (Usareu DfTutorial01) e clique no botão OK para continuar. Uma nova caixda de diálogo, mostrada na Figura 1-3, lhe permitirá escolher entre os modelos de projeto disponíveis.</p>
<p><a title="Figura 1-3. Escolha do modelo de projeto da aplicação" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-3.jpg" target="_blank"><img class="alignnone size-medium wp-image-93" title="Introdução ao ASP.NET MVC - Figura 1-3" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-3-300x271.jpg" alt="Introdução ao ASP.NET MVC - Figura 1-3" width="300" height="271" /></a><br />
Figura 1-3. Escolha do modelo de projeto da aplicação</p>
<p>A opção Empty criará um projeto contendo somente o mínimo de arquivos exigidos para uma aplicação do tipo ASP.NET MVC. A opção Internet Application cria o projeto juntamente com um pequeno modelo para que você possa modificar e construir, incluindo um tema, navegação, páginas e o registro de usuários e autenticação. A opção Intranet Application é projetada para ambientes que realizam a autenticação de usuários através do Active Directory.</p>
<p>Por enquanto vamos prosseguir selecione a opção Empty e deixe desmarcada a opção Use HTML5 semantic markup e clique em OK.</p>
<p>A Figura 1-4 demonstra os arquivos básicos do projeto inseridos pelo modelo de projeto, esta é a estrutura padrão para um projeto ASP.NET MVC 3.</p>
<p><a title="Figura 1-4. Arquivos criados no projeto vistos no Solution Explorer" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-4.jpg" target="_blank"><img class="alignnone size-medium wp-image-94" title="Introdução ao ASP.NET MVC - Figura 1-4" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-4-169x300.jpg" alt="Introdução ao ASP.NET MVC - Figura 1-4" width="169" height="300" /></a><br />
Figura 1-4. Arquivos criados no projeto vistos no Solution Explorer</p>
<ul>
<li><strong>Content</strong> &#8211; Pasta onde adicionamos os estilos (css);</li>
<li><strong>Controllers</strong> &#8211; Pasta onde iremos adicionar as classes de controle;</li>
<li><strong>Models</strong> &#8211; Pasta onde iremos adicionar as classes para persistência de dados;</li>
<li><strong>Scripts</strong> &#8211; Pasta onde iremos adicionar os scripts (js, jqeury,etc);</li>
<li><strong>Views</strong> &#8211; Pasta onde iremos adicionar as views (páginas).</li>
</ul>
<p>Neste ponto se você executar sua aplicação (Debug -&gt; Start Debugging ou F5) você verá uma tela contendo o erro 404 (Not Found Error) como é demonstrado na Figura 1-5, pois a aplicação não contém nada para executar.</p>
<p><a title="Figura 1-5. Tentando executar um projeto em branco" href="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-5.jpg" target="_blank"><img class="alignnone size-medium wp-image-95" title="Introdução ao ASP.NET MVC - Figura 1-5" src="http://diviforum.net/wp-content/uploads/2011/12/introducao_mvc_1-5-300x246.jpg" alt="Introdução ao ASP.NET MVC - Figura 1-5" width="300" height="246" /></a><br />
Figura 1-5. Tentando executar um projeto em branco</p>
<p>Se você usa o Internet Explorer como navegador principal de debug do projeto basta fechá-lo para que a depuração seja finalizada, caso contrário selecione Debug -&gt; Stop Debugging ou Shift+F5 no Visual Studio.</p>
<p>No próximo post deixaremos as coisas um pouco mais divertidas trabalhando com Controllers.</p>
<p>&nbsp;</p>
<p>Código fonte: <a  title='ASP.NET MVC – Iniciando - Código Fonte' href='http://diviforum.net/?wpdmact=process&did=MS5ob3RsaW5r' style="background:url('http://diviforum.net/wp-content/plugins/download-manager/icon/download.png') no-repeat;padding:3px 12px 12px 28px;font:bold 10pt verdana;">Download</a></p>
<img src="http://feeds.feedburner.com/~r/Diviforumnet/~4/_1ONE7R66_Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://diviforum.net/2011/introducao-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://diviforum.net/2011/introducao-aspnet-mvc/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.455 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-01-21 15:16:35 -->

