<?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>WebProNews &#187; HttpModule</title>
	<atom:link href="http://www.webpronews.com/tag/httpmodule/feed" rel="self" type="application/rss+xml" />
	<link>http://www.webpronews.com</link>
	<description>Breaking News in Tech, Search, Social, &#38; Business</description>
	<lastBuildDate>Mon, 13 Feb 2012 04:32:37 +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>ASP.NET: HttpModule for Query String Encryption</title>
		<link>http://www.webpronews.com/aspnet-httpmodule-for-query-string-encryption-2007-01</link>
		<comments>http://www.webpronews.com/aspnet-httpmodule-for-query-string-encryption-2007-01#comments</comments>
		<pubDate>Thu, 25 Jan 2007 16:44:01 +0000</pubDate>
		<dc:creator>Mads Kristensen</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[HttpModule]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://www.webpronews.com/?p=34763</guid>
		<description><![CDATA[URL parameters or query strings are often used to carry information that can be used by hackers to do identity theft or other unpleasant things.
]]></description>
			<content:encoded><![CDATA[<p>URL parameters or query strings are often used to carry information that can be used by hackers to do identity theft or other unpleasant things.</p>
<p>Consider the URL <i>example.com/?user=123&#038;account=456</i> and then imaging what a hacker could do with it. Security or not, sometimes you just don&#8217;t want the visitors to see all the query strings for whatever reason. </p>
<p>In those cases it would be nice if we could encrypt the entire query string so it wouldn&#8217;t carry any readable information. The problem with one big encrypted query string is that we would break all the code that referenced the query. Code like Request.QueryString["user"] would no longer work, but as usual ASP.NET has the answer to that problem. </p>
<p>What we need is an HttpModule that can turn the encrypted query string into a normal readable one, so that we can still use our old logic like Request.QueryString["user"]. In other words, we want the user to see this </p>
<p><b><code>?enc=VXzal017xHwKKPolDWQJoLACDqQ0fE//wGkgvRTdG/GgXIBDd1 </code></b></p>
<p>while your code sees this </p>
<p><b><code>?user=123&#038;account=456.</code></b></p>
<p><b>The HttpModule</b></p>
<p>The module we need for this task must be able to do a few simple things. It must be able to encrypt the regular query string so that all your current links will automatically be encrypted. It must also be able to decrypt it again so that you can write the code as you normally would. It must also provide a method for encrypting a regular query string if you don&#8217;t want to use automatic encryption.</p>
<p>The most important feature of the module is to make it totally plug &#8216;n play. You should be able to apply the module to any existing website and automatically have query string encryption and decryption without changing any of your code. </p>
<p><b>Implementation</b></p>
<p>Download the QueryStringModule.cs below and put it in the App_Code folder of your website. Then add the following lines to the web.config&#8217;s <system.web> section:</p>
<p><code>&lt;httpModules&gt;</p>
<p>&nbsp;&nbsp;  &lt;add type="QueryStringModule" name="QueryStringModule"/&gt;</p>
<p>&lt;/httpModules&gt;</code></p>
<p>Because automatic encryption is not always desirable the module has a comment that tells you how to turn it off. The module is well commented and should be easy to modify for any ASP.NET developer.</p>
<p><b>Example</b></p>
<p>You can encrypt query strings by using the Encrypt() method of the module from any web page or user control. </p>
<p><code>string query = QueryStringModule.Encrypt("user=123&#038;account=456");</code></p>
<p>Then just add the encrypted query string to the links that need encryption. You don&#8217;t need to use the method if you use automatic encryption.</p>
<p><b>Download</b></p>
<p><a href="http://www.madskristensen.dk/blog/ct.ashx?id=a6a478df-245a-4cd8-a3cc-80bb8c9c8004&#038;url=http%3a%2f%2fwww.madskristensen.dk%2fblog%2fcontent%2fbinary%2fQueryStringModule.zip" class="bluelink">QueryStringModule.zip (1,55 KB)</a></p>
<p><a href="http://www.madskristensen.dk/blog/CommentView,guid,a6a478df-245a-4cd8-a3cc-80bb8c9c8004.aspx" class="bluelink">Comments</a></p>
<p>Tag:   </p>
<p><a href="javascript:location.href='http://reddit.com/submit?url='+encodeURIComponent(location.href)+'&#038;title='+encodeURIComponent(document.title)"><img  src="http://images.ientrymail.com/webpronews/reddit.png" border=0>Reddit</a> | <a href="javascript:location.href='http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(document.location.href)+'&#038;t='+encodeURIComponent(document.title)+ '   '"><img src="http://images.ientrymail.com/webpronews/furl-pic.png" border=0> Furl</a> </p>
<p> Bookmark WebProNews: <a href="http://www.webpronews.com"><img src="http://images.ientrymail.com/webpronews/wpn-readit.jpg" border=0></a></p>
<p>Mads Kristensen currently works as a Senior Developer at Traceworks located<br />
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in<br />
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and<br />
web services in his daily work as well. A true .NET developer with great passion for the simple solution.</p>
<p>http://www.madskristensen.dk/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webpronews.com/aspnet-httpmodule-for-query-string-encryption-2007-01/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>ASP.NET: HttpModule for Moving ViewState to Bottom</title>
		<link>http://www.webpronews.com/aspnet-httpmodule-for-moving-viewstate-to-bottom-2006-11</link>
		<comments>http://www.webpronews.com/aspnet-httpmodule-for-moving-viewstate-to-bottom-2006-11#comments</comments>
		<pubDate>Tue, 28 Nov 2006 14:07:56 +0000</pubDate>
		<dc:creator>Mads Kristensen</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[HttpModule]]></category>
		<category><![CDATA[State]]></category>

		<guid isPermaLink="false">http://www.webpronews.com/?p=33174</guid>
		<description><![CDATA[There are two reasons why it is desirable to do so.
]]></description>
			<content:encoded><![CDATA[<p>There are two reasons why it is desirable to do so.</p>
<p>The first is for letting search engines see more of your content rather than the big portion of ViewState many sites have. </p>
<p>The other is perceived rendering time, which means that the content loads faster because it renders before the ViewState while the total rendering time remains the same. </p>
<p>That will decrease the load time of your website&#8217;s content.</p>
<p>Techniques to move the ViewState to the bottom of the WebForm has been published many times before. </p>
<p>What I wanted was adding the functionality to an HttpModule. </p>
<p>The technique to move the ViewState is borrowed from <a href="http://www.madskristensen.dk/blog/ct.ashx?id=60b79d7e-e838-4cbb-ad84-4c337f9275c8&#038;url=http%3a%2f%2fwww.hanselman.com%2fblog%2fMovingViewStateToTheBottomOfThePage.aspx" class="bluelink">Scott Hanselman</a> while the HttpModule implementation is my own. </p>
<p>As Scott writes, it is a very low impact technique (0.000995 second) even though it hasn&#8217;t been fully tested for a variety of scenarios. </p>
<p>The goal I&#8217;m trying to achieve is to build a reusable component that has 100% plug n play capabilities. </p>
<p>That&#8217;s where the HttpModule comes in. </p>
<p>You can just drop it into any existing website without changing any code.</p>
<p>I see no reasons why not to move the ViewState to the bottom, which makes me believe that Microsoft should have done that by default in the first place.</p>
<p><b>Implementation</b></p>
<p>Download the ViewstateModule.cs below and put in the App_Code folder of your website. Then add these lines to the web.config and you&#8217;re ready to go. </p>
<p><code>&lt;httpModules&gt;</p>
<p>&nbsp;&nbsp;  &lt;add type="ViewstateModule" name="ViewstateModule" /&gt;</p>
<p>&lt;/httpModules&gt;</code></p>
<p><b>Download</b></p>
<p><a href="http://www.madskristensen.dk/blog/ct.ashx?id=60b79d7e-e838-4cbb-ad84-4c337f9275c8&#038;url=http%3a%2f%2fwww.madskristensen.dk%2fblog%2fcontent%2fbinary%2fViewstateModule.zip" class="bluelink">ViewstateModule.zip (1,06 KB)</a></p>
<p>Tag: </p>
<p>Add to <a href="http://del.icio.us/post"  onclick="window.open('http://del.icio.us/post?v=4&#038;partner=wpn&#038;noui&#038;jump=close&#038;url='+encodeURIComponent(location.href)+'&#038;title='+encodeURIComponent(document.title),'delicious','toolbar=no,width=700,height=400'); return false;"   CLASS="printMailTop"><img  src=http://images.ientrymail.com/webpronews/delicious-pic.png border=0> Del.icio.us</a> | <a href="javascript:void window.open('http://digg.com/submit?phase=2&#038;url='+encodeURIComponent(window. location.href)+'&#038;ei=UTF-8','popup','width=520px,height=420px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0)"><img src=http://images.ientrymail.com/webpronews/digg-pic.png border=0> Digg</a> | <a href="javascript:location.href='http://reddit.com/submit?url='+encodeURIComp onent(location.href)+'&#038;title='+encodeURIComponent(document.title)"><img  src=http://images.ientrymail.com/webpronews/reddit.png border=0>Reddit</a> | <a href="javascript:location.href='http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(document.location.href)+'&#038;t='+encodeURIComponent(document.title)+ ' '"><img src=http://images.ientrymail.com/webpronews/furl-pic.png border=0> Furl</a></p>
<p>Bookmark WebProNews: <a href=http://www.webpronews.com><img src=http://images.ientrymail.com/webpronews/wpn-readit.jpg border=0></a></p>
<p>Mads Kristensen currently works as a Senior Developer at Traceworks located<br />
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in<br />
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and<br />
web services in his daily work as well. A true .NET developer with great passion for the simple solution.</p>
<p>http://www.madskristensen.dk/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webpronews.com/aspnet-httpmodule-for-moving-viewstate-to-bottom-2006-11/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Use an HttpModule to Spam-proof Your Website</title>
		<link>http://www.webpronews.com/use-an-httpmodule-to-spamproof-your-website-2006-11</link>
		<comments>http://www.webpronews.com/use-an-httpmodule-to-spamproof-your-website-2006-11#comments</comments>
		<pubDate>Wed, 01 Nov 2006 15:59:56 +0000</pubDate>
		<dc:creator>Mads Kristensen</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[HttpModule]]></category>
		<category><![CDATA[Spam]]></category>
		<category><![CDATA[Website]]></category>

		<guid isPermaLink="false">http://www.webpronews.com/?p=32494</guid>
		<description><![CDATA[Every time an email address is written on a website, it allows spam robots to collect it and abuse it. If you have a website (e.g. blog or forum) that displays the users e-mail address it would be a nice service to mask it for the spam robots.
]]></description>
			<content:encoded><![CDATA[<p>Every time an email address is written on a website, it allows spam robots to collect it and abuse it. If you have a website (e.g. blog or forum) that displays the users e-mail address it would be a nice service to mask it for the spam robots.</p>
<p>The safest way to display an e-mail address is to break it up and convert it to something like &#8220;name at company dot com&#8221;. However, there are a lot of problems involved with that approach. It is difficult to read and you can&#8217;t make it into a hyperlink like &#8220;mailto:name at company dot com&#8221;. If you want to make it into a hyperlink, the best way would be to use a JavaScript function similar to this:</p>
<p><code>function SendMail(name, company, domain) </p>
<p>{</p>
<p>&nbsp;&nbsp;  link = 'mai' + 'lto:' + name + '@' + company + '.' + domain;</p>
<p>&nbsp;&nbsp;  window.location.replace(link);</p>
<p>}</code></p>
<p>Then call that method with a hyperlink like this:</p>
<p><code>&lt;a href="JavaScript:SendMail('name', 'company', 'domain');void(0)"&gt;name at company dot com&lt;/a&gt;</code></p>
<p>That will make it pretty difficult to parse for a spam robot. </p>
<p>Another approach is to encode the characters into hex code which is perfectly readable for all browsers, but can proof to be more difficult to parse by robots but not impossible. What a robot can do is to just decode the entire HTML document from hex values into clear text, which will expose the e-mail addresses. But if we mixed clear text and hex values it will be much more difficult for the robot. That&#8217;s what the following HttpModule does.</p>
<p><b>HttpModule</b></p>
<p>The module replaces all e-mail addresses on your website with the mixed hex/clear text characters. It turns this </p>
<p><code>&lt;a href="mailto:name@company.com"&gt;name@company.com&lt;/a&gt;</code></p>
<p>Into this</p>
<p><code>&lt;a href="&#109;ai&#108;to:&#110;am&#101;&#64;c&#111;&#109;p&#97;n&#121;&#46;c&#111;m"&gt;<br />
n&#97;&#109;e&#64;&#99;&#111;m&#112;any.c&#111;&#109;&lt;/a&gt;</code></p>
<p>It uses the System.Random class to do the mix of the clear text with the hex values. The primary methods in the modules are the ones that through regex, replaces the clear text addresses.</p>
<p><code>private static Regex _Regex = new Regex("(mailto:|)(\\w+[a-zA-Z0-9.-_]*)@(\\w+).(\\w+)");</p>
<p>private static Random _Random = new Random();</p>
<p>private static string EncodeEmails(string html)</p>
<p>{</p>
<p>&nbsp;&nbsp;  foreach (Match match in _Regex.Matches(html))</p>
<p>&nbsp;&nbsp;  {</p>
<p>&nbsp;&nbsp;&nbsp;    html = html.Replace(match.Value, Encode(match.Value));</p>
<p>&nbsp;&nbsp;  }</p>
<p> &nbsp;&nbsp;&nbsp;  return html;</p>
<p>}</p>
<p>&nbsp;&nbsp; private static string Encode(string value)</p>
<p>{</p>
<p>&nbsp;&nbsp;  StringBuilder sb = new StringBuilder();</p>
<p>&nbsp;&nbsp;  for (int i = 0; i < value.Length; i++)</p>
<p>&nbsp;&nbsp;  {</p>
<p>&nbsp;&nbsp;&nbsp;    if (_Random.Next(2) == 1)</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;      sb.AppendFormat("&#{0};", Convert.ToInt32(value[i]));</p>
<p>&nbsp;&nbsp;&nbsp;    else</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;      sb.Append(value[i]);</p>
<p>&nbsp;&nbsp;  }</p>
<p>&nbsp;&nbsp;  return sb.ToString();<br />
}</code></p>
<p><b>Implementation</b></p>
<p>You can add this module to any existing web applications without breaking any code. Download the EmailSpamModule.cs below and place it in the App_Code folder on your website. Then add the following to the web.config:</p>
<p><code>&lt;httpModules&gt;</p>
<p>&nbsp;&nbsp;  &lt;add type="EmailSpamModule" name="EmailSpamModule" /&gt;<br />
&lt;/httpModules&gt;</code></p>
<p>Even though the module makes it much more difficult to decode any e-mail address, it is still my advice that you use the JavaScript method if possible. If you're lazy or don't get paid by the hour, go for the module.</p>
<p><b>Download</b></p>
<p><a href="http://www.madskristensen.dk/blog/ct.ashx?id=01ec18cf-9f67-43b2-a067-f4049a1225e7&#038;url=http%3a%2f%2fwww.madskristensen.dk%2fblog%2fcontent%2fbinary%2fEmailSpamModule.zip" class="bluelink">EmailSpamModule.zip (1,16 KB)</a></p>
<p><a href="http://www.madskristensen.dk/blog/CommentView,guid,01ec18cf-9f67-43b2-a067-f4049a1225e7.aspx" class="bluelink">Comments</a></p>
<p>Tag: </p>
<p>Add to <a href="http://del.icio.us/post" onclick="window.open('http://del.icio.us/post?v=4&#038;partner=wpn&#038;noui&#038;jump=clos   e&#038;url='+encodeURIComponent(location.href)+'&#038;title='+encodeURIComponent(docum ent.title),'delicious','toolbar=no,width=700,height=400'); return false;"   CLASS="printMailTop"><img src=http://images.ientrymail.com/webpronews/delicious-pic.png border=0> Del.icio.us</a> | <a href="javascript:void   window.open('http://digg.com/submit?phase=2&#038;url='+encodeURIComponent(window. location.href)+'&#038;ei=UTF-8','popup','width=520px,height=420px,status=0,locati   on=0,resizable=1,scrollbars=1,left=100,top=50',0)"><img src=http://images.ientrymail.com/webpronews/digg-pic.png border=0> Digg</a> | <a   href="javascript:location.href='http://reddit.com/submit?url='+encodeURIComp onent(location.href)+'&#038;title='+encodeURIComponent(document.title)"><img   src=http://images.ientrymail.com/webpronews/reddit.png border=0>Reddit</a> | <a href="javascript:location.href='http://www.furl.net/storeIt.jsp?u='+encodeUR   IComponent(document.location.href)+'&#038;t='+encodeURIComponent(document.title)+ ' '"><img src=http://images.ientrymail.com/webpronews/furl-pic.png border=0>   Furl</a></p>
<p>Bookmark WebProNews: <a href=http://www.webpronews.com><img src=http://images.ientrymail.com/webpronews/wpn-readit.jpg border=0></a></p>
<p>Mads Kristensen currently works as a Senior Developer at Traceworks located<br />
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in<br />
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and<br />
web services in his daily work as well. A true .NET developer with great passion for the simple solution.</p>
<p>http://www.madskristensen.dk/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webpronews.com/use-an-httpmodule-to-spamproof-your-website-2006-11/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 1/19 queries in 0.015 seconds using memcached
Object Caching 293/333 objects using memcached

Served from: webpronews.com @ 2012-02-13 05:02:58 -->
