<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Veggerby : IBlog</title>
	<atom:link href="http://blog.veggerby.dk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.veggerby.dk</link>
	<description>Low decoupling, highly incoherent</description>
	<lastBuildDate>Tue, 22 Nov 2011 12:50:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.veggerby.dk' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Veggerby : IBlog</title>
		<link>http://blog.veggerby.dk</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.veggerby.dk/osd.xml" title="Veggerby : IBlog" />
	<atom:link rel='hub' href='http://blog.veggerby.dk/?pushpress=hub'/>
		<item>
		<title>SQL Script to Get Row Count of All Tables in Database</title>
		<link>http://blog.veggerby.dk/2010/05/28/sql-script-to-get-row-count-of-all-tables-in-database/</link>
		<comments>http://blog.veggerby.dk/2010/05/28/sql-script-to-get-row-count-of-all-tables-in-database/#comments</comments>
		<pubDate>Fri, 28 May 2010 19:46:20 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2010/05/28/sql-script-to-get-row-count-of-all-tables-in-database/</guid>
		<description><![CDATA[There is an undocumented built-in stored procedure than iterates over all tables in a database and executes a SQL script &#34;sp_msforeachtable&#34; which makes the job pretty straightforward: sp_msforeachtable &#34;SELECT '?', COUNT(*) FROM ?&#34; Another nifty little sproc to use is the sp_spaceused which will besides row count return reserved size, data size, index size and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=145&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There is an undocumented built-in stored procedure than iterates over all tables in a database and executes a SQL script &quot;sp_msforeachtable&quot; which makes the job pretty straightforward:
<pre>sp_msforeachtable &quot;SELECT '?', COUNT(*) FROM ?&quot;</pre>
<p>
  <br />Another nifty little sproc to use is the <a href="http://msdn.microsoft.com/en-us/library/ms188776.aspx">sp_spaceused</a> which will besides row count return reserved size, data size, index size and unused size of a given table. Combine the two and you get a pretty nice list: </p>
<pre>CREATE TABLE #TempTable
(
    tableName varchar(100),
    numberofRows varchar(100),
    reservedSize varchar(50),
    dataSize varchar(50),
    indexSize varchar(50),
    unusedSize varchar(50)
)
GO

EXEC sp_msforeachtable &quot;INSERT #TempTable EXEC sp_spaceused '?'&quot;
GO

SELECT * FROM #TempTable

DROP TABLE #TempTable
GO</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/145/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/145/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/145/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=145&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2010/05/28/sql-script-to-get-row-count-of-all-tables-in-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>OAuth for Dummies</title>
		<link>http://blog.veggerby.dk/2009/10/06/oauth-for-dummies/</link>
		<comments>http://blog.veggerby.dk/2009/10/06/oauth-for-dummies/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 20:40:00 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[OAuth]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/29/oauth-for-dummies/</guid>
		<description><![CDATA[Having developed a little feature where I had to publish a Tweet to uh… Twitter, I did a checkup on how OAuth actually works. If you have the time you can go through Beginner’s Guide to OAuth, which is really excellent and was my source or introduction to OAuth. I’ll just condense it a little [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=132&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having developed a little feature where I had to publish a Tweet to uh… <a href="http://twitter.com/">Twitter</a>, I did a checkup on how <a href="http://oauth.net/">OAuth</a> actually works. If you have the time you can go through <a href="http://hueniverse.com/oauth/">Beginner’s Guide to OAuth</a>, which is really excellent and was my source or introduction to OAuth. I’ll just condense it a little further, mostly because it is a good way to actually “get it”.</p>
<h2>What is OAuth?</h2>
<p><strong>OAUth makes it possible for providers to communicate in a secure and authenticated manor, without needing to share user secrets (username/password).</strong> For example it can allow the users of my web application to post Tweets to their Twitter account without needing to specify their username and password (except if the need to login to the Twitter site).</p>
<h2>Who is involved?</h2>
<p>Just to set the scene and get into the terms used, the actors involved are:</p>
<p>We want to get access to the <strong>Service Provider</strong>, e.g. Twitter.</p>
<p>The <strong>Consumer </strong>would like to access a resource on the Service Provider, e.g. my application.</p>
<p>The <strong>User</strong> want to access a resource on the Service Provider via the Consumer, e.g. post a Tweet using my application.</p>
<h2>How does it work?</h2>
<p>Seen from a larger perspective the idea is that the 3 actors (the Service Provider, the Consumer and the User) communicate with each other in such a way that all agree on who is who.</p>
<p>In more technical terms, all 3 actors generates and present various tokens (share secrets) to each other, which when combined establishes a trusted relationship between the Consumer and the Service Provider on behalf of the User.</p>
<h3>Step-by-Step</h3>
<p>A User want to perform an action on the Consumer which requires access to the/a protected resource on the Service Provider, e.g. create a Tweet.</p>
<ol>
<li>The Consumer contacts the Service Provider, requesting a <strong>Request Token</strong> and a <strong>Request Secret</strong>. </li>
<li>The User (e.g. his/her browser) is then redirected to the Service Provider presenting the <strong>Request Token</strong>. </li>
<li>The Service Provider validates the user and request approval from the User that the Consumer (found via the <strong>Request Token</strong>) can access the User’s protected resource. </li>
<li>The Service Provider generates an <strong>Access Token</strong> and an <strong>Access Secret</strong>. </li>
<li>The User (e.g. his/her browser) is then redirected to the Consumer, presenting the <strong>Access Token</strong> (the <strong>Access Secret</strong> is kept um… secret). </li>
<li>The Consumer now takes the <strong>Access Token</strong> and the <strong>Request Secret</strong> and asks the Service Provider for the <strong>Access Secret</strong>. </li>
<li>Once the Consumer has the <strong>Access Token</strong> and the <strong>Access Secret</strong>, it can access the protected resource. </li>
</ol>
<p>The point of presenting the <strong>Request Secret</strong> to the Service Provider in step 6 is so that replays cannot be performed using the <strong>Access Token</strong> alone.</p>
<p>The <strong>Tokens</strong> are used to communicate between the Consumer and the Service Provider <u>via</u> the User (his/her browser). The <strong>Secrets</strong> are kept between the Consumer and the Service Provider.</p>
<h2>Now what?</h2>
<p>Once the relationship is in place, the “real” communication can take place. This is where it gets hairy and where we’ll stop for this dummy introduction. </p>
<p>However during my implementation I found a little problem with the way .NET <a href="http://msdn.microsoft.com/en-us/library/zttxte6w.aspx">UrlEncode</a> works – it is simply not compatible with OAuth. I found an <a href="http://stackoverflow.com/questions/846487/how-to-get-uri-escapedatastring-to-comply-with-rfc-3986">implementation</a> by <a href="http://blog.nerdbank.net/">Andrew Arnott</a>, who is OAuth/OpenID aficionado and author of <a href="https://www.ohloh.net/p/dotnetopenauth/">DotNetOpenAuth</a> that does this and is <a href="http://www.faqs.org/rfcs/rfc3986.html">RFC 3986</a> compliant (it basically used the UrlEncode from .NET and then fixes what is broken):</p>
<pre>
/// &lt;summary&gt;
/// The set of characters that are unreserved in RFC 2396 but are NOT unreserved in RFC 3986.
/// &lt;/summary&gt;
private static readonly string[] UriRfc3986CharsToEscape = new[] { &quot;!&quot;, &quot;*&quot;, &quot;&#039;&quot;, &quot;(&quot;, &quot;)&quot; };

/// &lt;summary&gt;
/// Escapes a string according to the URI data string rules given in RFC 3986.
/// &lt;/summary&gt;
/// &lt;param name=&quot;value&quot;&gt;The value to escape.&lt;/param&gt;
/// &lt;returns&gt;The escaped value.&lt;/returns&gt;
/// &lt;remarks&gt;
/// The &lt;see cref=&quot;Uri.EscapeDataString&quot;/&gt; method is &lt;i&gt;supposed&lt;/i&gt; to take on
/// RFC 3986 behavior if certain elements are present in a .config file.  Even if this
/// actually worked (which in my experiments it &lt;i&gt;doesn&#039;t&lt;/i&gt;), we can&#039;t rely on every
/// host actually having this configuration element present.
/// &lt;/remarks&gt;

public static string UrlEncodeRfc3986(this string value)
{
    // Start with RFC 2396 escaping by calling the .NET method to do the work.
    // This MAY sometimes exhibit RFC 3986 behavior (according to the documentation).
    // If it does, the escaping we do that follows it will be a no-op since the
    // characters we search for to replace can&#039;t possibly exist in the string.
    var escaped = new StringBuilder(Uri.EscapeDataString(value));

    // Upgrade the escaping to RFC 3986, if necessary.
    for (int i = 0; i &lt; UriRfc3986CharsToEscape.Length; i++)
    {
        escaped.Replace(UriRfc3986CharsToEscape[i], Uri.HexEscape(UriRfc3986CharsToEscape[i][0]));
    }

    // Return the fully-RFC3986-escaped string.
    return escaped.ToString();
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/132/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/132/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/132/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=132&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/10/06/oauth-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>ISO 8601/RFC 3339 Compatible Dates</title>
		<link>http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/</link>
		<comments>http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 15:09:00 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[ISO]]></category>
		<category><![CDATA[RFC]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/</guid>
		<description><![CDATA[There are not standard format specifiers for date that takes a date and converts it to an ISO 8601 or RFC 3339 compatible date. Here are two extension methods that does just that. public static string ToISO8601(this DateTime date) { return date.ToString(&#34;yyyy-MM-dd&#34;); } public static string ToRFC3339(this DateTime date) { return date.ToUniversalTime().ToString(&#34;yyyy-MM-ddThh:mm:ssZ&#34;); }<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=124&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are not standard format specifiers for date that takes a date and converts it to an <a href="http://en.wikipedia.org/wiki/ISO_8601#Dates">ISO 8601</a> or <a href="http://www.faqs.org/rfcs/rfc3339.html">RFC 3339</a> compatible date. Here are two extension methods that does just that.</p>
<pre>
public static string ToISO8601(this DateTime date)
{
    return date.ToString(&quot;yyyy-MM-dd&quot;);
}

public static string ToRFC3339(this DateTime date)
{
    return date.ToUniversalTime().ToString(&quot;yyyy-MM-ddThh:mm:ssZ&quot;);
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=124&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/10/04/iso-8601rfc-3339-compatible-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>Generating a Slug From a String</title>
		<link>http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/</link>
		<comments>http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 18:41:00 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Slug]]></category>
		<category><![CDATA[Unicode]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/</guid>
		<description><![CDATA[I can’t (and won’t) take full credit for this extension method. The hardcore Unicode stuff is from Michael Kaplan’s blog (jeez, he is hardcore). There is a little danish “stuff” included, for special characters æ, ø and å, which can also be written “ae”, “oe” an “aa”. public static string ToSlug(this string message) { // [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=123&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I can’t (and won’t) take full credit for this extension method. The hardcore Unicode stuff is from <a href="http://blogs.msdn.com/michkap/archive/2007/05/14/2629747.aspx">Michael Kaplan’s blog</a> (jeez, he is hardcore). There is a little danish “stuff” included, for special characters æ, ø and å, which can also be written “ae”, “oe” an “aa”.</p>
<pre>
public static string ToSlug(this string message)
{
    // replace space with -
    message = Regex.Replace(message, @&quot;[\s/\\\.,+|_]+&quot;, &quot;-&quot;);

    // normalize the message
    message = message.Normalize(NormalizationForm.FormD);
    message = message.Replace(&quot;&#248;&quot;, &quot;oe&quot;).Replace(&quot;&#216;&quot;, &quot;Oe&quot;).Replace(&quot;&#230;&quot;, &quot;ae&quot;).Replace(&quot;&#198;&quot;, &quot;Ae&quot;).Replace(&quot;&#229;&quot;, &quot;aa&quot;).Replace(&quot;&#197;&quot;, &quot;Aa&quot;);

    StringBuilder result = new StringBuilder();
    for (int i = 0; i &lt; message.Length; i++)
    {
        UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(message[i]);
        if (uc != UnicodeCategory.NonSpacingMark)
        {
            result.Append(message[i]);
        }
    }
    return Regex.Replace(result.ToString().Normalize(NormalizationForm.FormC), @&quot;[^a-zA-Z0-9\-]&quot;, &quot;&quot;).ToLower();
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=123&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/10/02/generating-a-slug-from-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET MVC Gravatar HtmlHelper</title>
		<link>http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/</link>
		<comments>http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 19:08:00 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[Gravatar]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/</guid>
		<description><![CDATA[Here is a quick little URL Helper extension method to add Gravatar images/photos/avatars to your page: public static string GravatarUrl(this UrlHelper url, string email, int size) { string imageUrl = ConfigurationManager.AppSettings[&#34;DefaultGravatar&#34;]; if (imageUrl.StartsWith(&#34;~/&#34;)) { imageUrl = url.Absolute(imageUrl); } if (string.IsNullOrEmpty(email)) { return imageUrl; } string md5 = email.ToLowerInvariant().MD5(); return string.Format( &#34;http://www.gravatar.com/avatar/{0}.jpg?d={1}&#38;s={2}&#38;r=g&#34;, md5.ToLowerInvariant(), url.Encode(imageUrl), size); } [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=122&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a quick little <a href="http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx">URL Helper</a> extension method to add <a href="http://gravatar.com/">Gravatar</a> images/photos/avatars to your page:</p>
<pre>
public static string GravatarUrl(this UrlHelper url, string email, int size)
{
    string imageUrl = ConfigurationManager.AppSettings[&quot;DefaultGravatar&quot;];
    if (imageUrl.StartsWith(&quot;~/&quot;))
    {
        imageUrl = url.Absolute(imageUrl);
    }

    if (string.IsNullOrEmpty(email))
    {
        return imageUrl;
    }

    string md5 = email.ToLowerInvariant().MD5();
    return string.Format(
        &quot;http://www.gravatar.com/avatar/{0}.jpg?d={1}&amp;s={2}&amp;r=g&quot;,
        md5.ToLowerInvariant(),
        url.Encode(imageUrl),
        size);
}

public static string GravatarUrl(this UrlHelper url, string email)
{
    return url.GravatarUrl(email, 32);
}
</pre>
<p>It uses another custom URL Helper extension method Absolute to generate an absolute URL to a default image (based on an application relative url).</p>
<p>The Absolute extension method is similar to the ActionAbsolute method <a href="http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/">I posted earlier</a>:</p>
<pre>
public static string Absolute(this UrlHelper url, string contentUrl)
{
    return new Uri(GetBaseUrl(url), url.Content(contentUrl))
        .AbsoluteUri;
}
</pre>
<p>And it also used the MD5 extension method <a href="http://blog.veggerby.dk/2009/09/29/md5-extension-method/">from yesterdays post</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/122/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=122&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/09/30/asp-net-mvc-gravatar-htmlhelper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>MD5 Extension Method</title>
		<link>http://blog.veggerby.dk/2009/09/29/md5-extension-method/</link>
		<comments>http://blog.veggerby.dk/2009/09/29/md5-extension-method/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 12:38:00 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Extension Methods]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[Secure Hash]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/29/md5-extension-method/</guid>
		<description><![CDATA[A nifty little extension method that generated the MD5/SHA-1 hash of a string. These methods are a continuation of my previous post: public static string MD5(this string value) { System.Security.Cryptography.MD5 algorithm = System.Security.Cryptography.MD5.Create(); byte[] data = Encoding.ASCII.GetBytes(value); data = algorithm.ComputeHash(data); string md5 = &#34;&#34;; for (int i = 0; i &#60; data.Length; i++) { md5 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=121&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A nifty little extension method that generated the MD5/SHA-1 hash of a string. These methods are a continuation of <a href="http://blog.veggerby.dk/2008/07/27/formsauthenticationhashpasswordforstoringinconfigfile-continued/">my previous post</a>:</p>
<pre>
public static string MD5(this string value)
{
    System.Security.Cryptography.MD5 algorithm =
        System.Security.Cryptography.MD5.Create();

    byte[] data = Encoding.ASCII.GetBytes(value);
    data = algorithm.ComputeHash(data);
    string md5 = &quot;&quot;;
    for (int i = 0; i &lt; data.Length; i++)
    {
        md5 += data[i].ToString(&quot;x2&quot;).ToLower();
    }

    return md5;
}
</pre>
<p>Just substitute <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.md5.aspx">MD5</a> for <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha1.aspx">SHA1</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256.aspx">SHA256</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha384.aspx">SHA384</a>, <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha512.aspx">SHA512</a> or <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.ripemd160.aspx">RIPEMD160</a> which ever hash algorithm fits your needs.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/121/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=121&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/09/29/md5-extension-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>Relative Time Description</title>
		<link>http://blog.veggerby.dk/2009/09/28/relative-time-description/</link>
		<comments>http://blog.veggerby.dk/2009/09/28/relative-time-description/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 19:46:48 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Dates]]></category>
		<category><![CDATA[Extension Methods]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/09/28/relative-time-description/</guid>
		<description><![CDATA[Showing an absolute date on a webpage, e.g. January 22, 2009 13:01, is of course a very normal way to do it, apart from various different date formats, it is easily read and consumed. However if the date is shown in a context where the absolute date is of little importance, but it is more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=125&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Showing an absolute date on a webpage, e.g. January 22, 2009 13:01, is of course a very normal way to do it, apart from various different date formats, it is easily read and consumed. However if the date is shown in a context where the absolute date is of little importance, but it is more important to know if it was a long time ago, just now or maybe just in a couple of minutes, a relative and more descriptive method is better. </p>
<p>For example the date mentioned above might be described as “8 months ago”. Just by giving it a quick glance you get an idea about when this event occurred.</p>
<p>For this here are a couple of extension methods that generate this descriptive text based on a given time:</p>
<pre>
public static string ToRelativeTime(this DateTime from)
{
    DateTime now = DateTime.Now;
    return from.ToRelativeTime(now);
}

public static string ToRelativeTime(this DateTime from, bool usePreAndSuffix)
{
    DateTime now = DateTime.Now;
    return from.ToRelativeTime(now, usePreAndSuffix);
}

public static string ToRelativeTime(this DateTime from, DateTime to)
{
    return from.ToRelativeTime(to, true);
}

public static string ToRelativeTime(this DateTime from, DateTime to, bool usePreAndSuffix)
{
    string prefix = usePreAndSuffix &amp;&amp; (from &gt; to) ? &quot;in &quot; : string.Empty;
    string suffix = !usePreAndSuffix || (from &gt; to) ? string.Empty : &quot; ago&quot;;

    // is more than 1 year?
    if (from &gt; to)
    {
        DateTime d = from;
        from = to;
        to = d;
    }

    int years = to.Year - from.Year;
    if ((to.Month &lt; from.Month) || ((to.Month == from.Month) &amp;&amp; (to.Day &lt; from.Day)))
    {
        years--;
    }

    if (years &gt; 1)
    {
        return string.Format(&quot;{0}{1} years{2}&quot;, prefix, years, suffix);
    }
    else if (years == 1)
    {
        return string.Format(&quot;{0}1 year{1}&quot;, prefix, suffix);
    }

    // less than 1 year, is more than 1 month?
    int months = to.Month - from.Month;
    if (months &lt; 0)
    {
        months += 12;
    }

    if ((to.Day &lt; from.Day) || ((to.Day == from.Day) &amp;&amp; (to.TimeOfDay &lt; from.TimeOfDay)))
    {
        months--;
    }

    if (months &gt; 1)
    {
        return string.Format(&quot;{0}{1} months{2}&quot;, prefix, months, suffix);
    }
    else if (months == 1)
    {
        return string.Format(&quot;{0}1 month{1}&quot;, prefix, suffix);
    }

    // less than 1 month, is more than 1 day/week?
    TimeSpan diff = to - from;
    if (diff.Days &gt; 7)
    {
        return string.Format(&quot;{0}{1} weeks{2}&quot;, prefix, diff.Days / 7, suffix);
    }
    else if (diff.Days &gt; 1)
    {
        return string.Format(&quot;{0}{1} days{2}&quot;, prefix, diff.Days, suffix);
    }
    else if (diff.Days == 1)
    {
        return string.Format(&quot;{0}1 day{1}&quot;, prefix, suffix);
    }

    // less than 1 day, is more than 1 hour?
    if (diff.Hours &gt; 1)
    {
        return string.Format(&quot;{0}{1} hours{2}&quot;, prefix, diff.Hours, suffix);
    }
    else if (diff.Hours == 1)
    {
        return string.Format(&quot;{0}1 hour{1}&quot;, prefix, suffix);
    }

    // less than 1 hour, is more than 1 minute?
    if (diff.Minutes &gt; 1)
    {
        return string.Format(&quot;{0}{1} minutes{2}&quot;, prefix, diff.Minutes, suffix);
    }
    else if (diff.Minutes == 1)
    {
        return string.Format(&quot;{0}1 minute{1}&quot;, prefix, suffix);
    }

    // less than 1 minute
    if (diff.Seconds == 1)
    {
        return string.Format(&quot;{0}1 second{1}&quot;, prefix, suffix);
    }
    else if (diff.Seconds &lt; 1)
    {

        return string.Format(&quot;{0}less than 1 second{1}&quot;, prefix, suffix);
    }

    return string.Format(&quot;{0}{1} seconds{2}&quot;, prefix, diff.Seconds, suffix);
}
</pre>
<p>This can of course be optimized for localization etc.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=125&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/09/28/relative-time-description/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>EF bloating</title>
		<link>http://blog.veggerby.dk/2009/06/25/ef-bloating/</link>
		<comments>http://blog.veggerby.dk/2009/06/25/ef-bloating/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 18:43:36 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[WCF]]></category>
		<category><![CDATA[entity framework]]></category>
		<category><![CDATA[rant]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/06/25/ef-bloating/</guid>
		<description><![CDATA[I just read a post from Cibrax aka Pablo M. Cibraro and remembered my old post on the “LINQ to SQL is dead” news. Especially the quote: They made a good work teaching us about how evil Datasets were for interoperability with other platforms, and now they came up with a solution like this, no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=118&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just read a post from <a href="http://weblogs.asp.net/cibrax/archive/2009/06/25/a-bad-idea-ef-entities-over-wcf.aspx">Cibrax aka Pablo M. Cibraro</a> and remembered <a href="http://blog.veggerby.dk/2008/11/01/adonet-entitity-framework-vs-linq-to-sql/">my old post</a> on the <a href="http://blogs.msdn.com/adonet/archive/2008/10/29/update-on-linq-to-sql-and-linq-to-entities-roadmap.aspx">“LINQ to SQL is dead” news</a>.</p>
<p>Especially the quote:</p>
<blockquote><p>They made a good work teaching us about how evil Datasets were for interoperability with other platforms, and now they came up with a solution like this, no way.</p>
</blockquote>
<p>Priceless…</p>
<p>On the topic from Cibrax’ post, I could not agree more, I am a strong believer in the explicitness of service design and the WCF “opt-in” approach. How else would you know what is on the wire!? Similar to how you would choose ASP.NET MVC over classic ASP.NET WebForms if you want complete control of your HTML. Similar even to WCF vs. ASMX (on a high level).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=118&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/06/25/ef-bloating/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting an absolute URL from ASP.NET Webforms</title>
		<link>http://blog.veggerby.dk/2009/01/15/getting-an-absolute-url-from-aspnet-webforms/</link>
		<comments>http://blog.veggerby.dk/2009/01/15/getting-an-absolute-url-from-aspnet-webforms/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 18:33:50 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/01/15/getting-an-absolute-url-from-aspnet-webforms/</guid>
		<description><![CDATA[Related to the post Getting an absolute URL from ASP.NET MVC here is the corresponding ASP.NET Webforms version (not as extension methods): public static Uri GetBaseUrl(HttpRequest request) { Uri contextUri = new Uri(request.Url, request.RawUrl); UriBuilder realmUri = new UriBuilder(contextUri) { Path = request.ApplicationPath, Query = null, Fragment = null }; return realmUri.Uri; } public static [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=117&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Related to the post <a href="http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/">Getting an absolute URL from ASP.NET MVC</a> here is the corresponding ASP.NET Webforms version (not as extension methods):</p>
<pre>
public static Uri GetBaseUrl(HttpRequest request)
{
    Uri contextUri = new Uri(request.Url, request.RawUrl);
    UriBuilder realmUri = new UriBuilder(contextUri) { Path = request.ApplicationPath, Query = null, Fragment = null };
    return realmUri.Uri;
}

public static string GetAbsoluteUrl(HttpRequest request, string relativeUrl)
{
    return new Uri(GetBaseUrl(request), VirtualPathUtility.ToAbsolute(relativeUrl)).AbsoluteUri;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/117/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/117/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/117/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=117&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/01/15/getting-an-absolute-url-from-aspnet-webforms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting an absolute URL from ASP.NET MVC</title>
		<link>http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/</link>
		<comments>http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 22:40:15 +0000</pubDate>
		<dc:creator>veggerby</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/</guid>
		<description><![CDATA[I have been in situations where I need to generate an absolute URL to a specific action in an ASP.NET MVC application. The main problem mostly lies in getting the “domain” part of the URL. The only way to do this is to examine the request URL. I came across a very nice method of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=116&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been in situations where I need to generate an <u>absolute</u> URL to a specific action in an <a href="http://asp.net/mvc">ASP.NET MVC</a> application. The main problem mostly lies in getting the “domain” part of the URL. The only way to do this is to examine the request URL. I came across a very nice method of doing this during an encounter with the <a href="http://code.google.com/p/dotnetopenid/">dotnetopenid</a>.&#160; </p>
<pre>
public static Uri GetBaseUrl(this UrlHelper url)
{
    Uri contextUri = new Uri(url.RequestContext.HttpContext.Request.Url, url.RequestContext.HttpContext.Request.RawUrl);
    UriBuilder realmUri = new UriBuilder(contextUri) { Path = url.RequestContext.HttpContext.Request.ApplicationPath, Query = null, Fragment = null };
    return realmUri.Uri;
}

public static string ActionAbsolute(this UrlHelper url, string actionName, string controllerName)
{
    return new Uri(GetBaseUrl(url), url.Action(actionName, controllerName)).AbsoluteUri;
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/veggerby.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/veggerby.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/veggerby.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/veggerby.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/veggerby.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/veggerby.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/veggerby.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/veggerby.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.veggerby.dk&amp;blog=16143280&amp;post=116&amp;subd=veggerby&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.veggerby.dk/2009/01/13/getting-an-absolute-url-from-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/186533baa84d7fe7d5281a5644c9c6da?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veggerby</media:title>
		</media:content>
	</item>
	</channel>
</rss>
