<?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>BPulse == Ben Parsons &#187; asp.net</title>
	<atom:link href="http://www.bpulse.co.uk/tag/asp-net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bpulse.co.uk</link>
	<description>Web development from London</description>
	<lastBuildDate>Wed, 04 May 2011 13:34:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Kiss Academy 2011</title>
		<link>http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011#comments</comments>
		<pubDate>Mon, 18 Apr 2011 13:34:18 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[blackberry]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=184</guid>
		<description><![CDATA[Kiss Academy gives fans of Kiss the opportunity to learn more about the work done by Kiss through workshops and advice from recognised mentors. Entrants are required to select which workshops they&#8217;d like to be involved in, then write about &#8230; <a href="http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-1home.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-1home-150x150.png" alt="" title="kissacademy2011-1home" width="150" height="150" class="alignleft size-thumbnail wp-image-192" /></a><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-2workshops.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-2workshops-150x150.png" alt="" title="kissacademy2011-2workshops" width="150" height="150" class="alignleft size-thumbnail wp-image-193" /></a><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-3mentors.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/kissacademy2011-3mentors-150x150.png" alt="" title="kissacademy2011-3mentors" width="150" height="150" class="alignleft size-thumbnail wp-image-194" /></a><br />
<br clear="all" /><br />
<a href="http://academy.totalkiss.com" target="_blank">Kiss Academy</a> gives fans of Kiss the opportunity to learn more about the work done by Kiss through workshops and advice from recognised mentors. Entrants are required to select which workshops they&#8217;d like to be involved in, then write about why they&#8217;re the most suitable choice.</p>
<p>The development consisted primarily of an entry form with some JavaScript customisation and a second, smaller entry form. Additionally, the project required a custom Twitter feed, the implementation of which required building a server-side component to retrieve and format the data. A post with more technical information about the Twitter component is forthcoming.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/kiss-academy-2011/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ASP.NET to read the Facebook signed_request object passed to iframe tabs</title>
		<link>http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs</link>
		<comments>http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs#comments</comments>
		<pubDate>Wed, 13 Apr 2011 15:24:00 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fbml]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=141</guid>
		<description><![CDATA[Facebook recently announced that they are phasing out FMBL in favour of iframe tabs for pages. This article discusses how to extract information from the signed_request parameter passed into the iframe using Json.NET LINQ to JSON. Getting Started Firstly, if &#8230; <a href="http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Facebook <a href="http://developers.facebook.com/blog/post/462" target="_blank">recently announced</a> that they are phasing out FMBL in favour of iframe tabs for pages. This article discusses how to extract information from the signed_request parameter passed into the iframe using <a href="http://james.newtonking.com/pages/json-net.aspx" target="_blank">Json.NET LINQ to JSON</a>.</p>
<h2>Getting Started</h2>
<p>Firstly, if you don&#8217;t already have one, create a new app using the <a href="http://www.facebook.com/developers/apps.php" target="_blank">Facebook developers app</a>. Once your app is registered, select your app in the Developer app and click &#8220;Edit Settings&#8221;, then go to the &#8220;Facebook Integration&#8221; tab. In the &#8220;Page Tabs&#8221; section, give the name you&#8217;d like for your tab, make sure the type is set to &#8220;iframe&#8221;, then give the Tab URL. Secure and Edit URLs are optional.</p>
<p style="text-align: center;"><img class="size-full wp-image-153 aligncenter" title="Facebook Page Tabs" src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/pagetabs.png" alt="Facebook Page Tabs Settings" width="707" height="212" /></p>
<p>Go back to the &#8220;My Apps&#8221; page in the Facebook developers app and select your app. Click to go to the Application Profile Page, then click &#8220;Add to My Page&#8221; and select your page from the resulting dialog. This whole process is covered in more detail on the <a href="http://developers.facebook.com/docs/guides/canvas/#tabs" target="_blank">Facebook developers documentation</a>.</p>
<blockquote><p>If you find yourself getting an IIS 405 error (&#8220;HTTP verb used to access this page is not allowed&#8221;) make sure you specify the full path to the page you&#8217;re looking for. For example, using Web Forms, http://mydomain.com/folder will usually render http://mydomain.com/folder/Default.aspx when accessed from the browser. However, since Facebook is POSTing to the url you gave, IIS throws an error.</p></blockquote>
<h2>Reading signed_request</h2>
<p>Now onto the fun stuff. <a href="http://developers.facebook.com/docs/authentication/signed_request/" target="_blank">So it is written</a>, Facebook makes a POST to your page, and in doing so sends a signed_request value. See the previous link for more detail, but in short, the value is a string made up of a signature, a period (&#8220;.&#8221;) and a Base64-encoded JSON object. We&#8217;re interested in that JSON object, so we extract it from the string, the convert it from Base64 to a JSON object.</p>
<pre style="width: 100%; overflow: scroll;">string payload = Request.Form["signed_request"].Split('.')[1];
var encoding = new UTF8Encoding();
var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
var json = encoding.GetString(base64JsonArray);</pre>
<p>Now we have a string containing the JSON object, we can use the <a href="http://james.newtonking.com/projects/json/help/SelectToken.html" target="_blank">Json.NET LINQ TO JSON</a> functions to create a JObject containing the information:</p>
<pre>var o = JObject.Parse(json);</pre>
<p>Now we can query this object using SelectToken&#8230;</p>
<pre>bool liked = (bool)o.SelectToken("page.liked");</pre>
<p>&#8230;to extract information about the user, including whether or not they liked the page, their locale, and their age range. Facebook uses a range for ages to replace the <a href="http://developers.facebook.com/docs/reference/fbml/#visibility-on-profile" target="_blank">fbml visibility</a> tags.</p>
<h2>Conculsion</h2>
<p>Complete code:</p>
<pre style="width: 100%; overflow: scroll;">using Newtonsoft.Json.Linq;
using System.Text;

public partial class Page_Default : System.Web.UI.Page
{
    protected string output = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        output = "Whole thing:" +Request.Form["signed_request"];
        output += "Second part:" + Request.Form["signed_request"].Split('.')[1];

            try
            {
                string payload = Request.Form["signed_request"].Split('.')[1];
                var encoding = new UTF8Encoding();
                var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
                var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
                var json = encoding.GetString(base64JsonArray);
                var o = JObject.Parse(json);

                output += "Decoded:" + json;

                bool liked = (bool)o.SelectToken("page.liked");

                output += "Liked:" + liked.ToString();
            }
            catch (Exception ex)
            {
                output += "Extract failed: " + ex.Message;
            }
    }
}</pre>
<p>And this is the result:</p>
<p><a href="http://www.bpulse.co.uk/wp-content/uploads/2011/04/testpage.png"><img class="aligncenter size-full wp-image-171" title="Test Page" src="http://www.bpulse.co.uk/wp-content/uploads/2011/04/testpage.png" alt="Test Page Output" width="727" height="512" /></a></p>
<p>Part of the code in this article was adapted from <a href="http://stackoverflow.com/questions/3433252/how-to-decode-oauth-2-0-for-canvas-signed-request-in-c" target="_blank">this answer on Stack Overflow by Patrick Gidich</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/blog/using-asp-net-to-read-the-facebook-signed_request-object-passed-to-iframe-tabs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stan James</title>
		<link>http://www.bpulse.co.uk/portfolio/web/stan-james</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/stan-james#comments</comments>
		<pubDate>Fri, 18 Jun 2010 08:48:36 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[fhm]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[stanjames]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=109</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/stan-james/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>When In Rome</title>
		<link>http://www.bpulse.co.uk/portfolio/web/when-in-rome</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/when-in-rome#comments</comments>
		<pubDate>Tue, 18 May 2010 08:50:31 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[tv]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=114</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/when-in-rome/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starbucks Discoveries</title>
		<link>http://www.bpulse.co.uk/portfolio/web/starbucks-discoveries</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/starbucks-discoveries#comments</comments>
		<pubDate>Mon, 10 May 2010 08:54:06 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[heat]]></category>
		<category><![CDATA[heatradio]]></category>
		<category><![CDATA[podcast]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[starbucks]]></category>
		<category><![CDATA[thehits]]></category>
		<category><![CDATA[thehitsradio]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=116</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/starbucks-discoveries/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gillette Venus Embrace &quot;Five-Star Secrets Tour&quot; with Heat and More!</title>
		<link>http://www.bpulse.co.uk/portfolio/web/gillette-venus-embrace-tour-with-heat-and-more</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/gillette-venus-embrace-tour-with-heat-and-more#comments</comments>
		<pubDate>Thu, 02 Apr 2009 22:20:48 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[gillette]]></category>
		<category><![CDATA[heat]]></category>
		<category><![CDATA[more!]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=23</guid>
		<description><![CDATA[<strong><a href="http://www.embrace5startour.com/">www.embrace5startour.com</a></strong> <a href="http://www.bpulse.co.uk/portfolio/web/gillette-venus-embrace-tour-with-heat-and-more">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><!-- needs graphics --></p>
<table>
<tr>
<td><strong>Project</strong></td>
<td>Gillette Venus Embrace &#8220;Five-Star Secrets Tour&#8221;</td>
</tr>
<tr>
<td><strong>URL</strong></td>
<td><a href="http://www.embrace5startour.com/">http://www.embrace5startour.com/</a></td>
</tr>
<tr>
<td><strong>Brand(s)</strong></td>
<td><i>Heat</i> and <i>More!</i></td>
</tr>
<tr>
<td><strong>Date</strong></td>
<td>March-April 2009</td>
</tr>
<tr>
<td><strong>Employer</strong></td>
<td>Bauer Media (Online Advertising)</td>
</tr>
<tr>
<td><strong>Technologies</strong></td>
<td>ASP.Net (C#), Adobe Flash (AS3), JavaScript (including jQuery), MS SQLServer 2005</td>
</tr>
<tr>
<td><strong>Role</strong></td>
<td>Developer, front- and back-end</td>
</tr>
</table>
<p><!-- needs description --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/gillette-venus-embrace-tour-with-heat-and-more/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wanted promotion for FHM and Zoo</title>
		<link>http://www.bpulse.co.uk/portfolio/web/wanted</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/wanted#comments</comments>
		<pubDate>Thu, 26 Mar 2009 13:48:11 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[fhm]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[sqlserver]]></category>
		<category><![CDATA[zoo]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=73</guid>
		<description><![CDATA[BPulse developed two complete games in flash for this project. These were played consecutively, so players were restricted from playing the second game until the first was completed, encouraging replays. Players were unable to access the form to enter the &#8230; <a href="http://www.bpulse.co.uk/portfolio/web/wanted">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>BPulse developed two complete games in flash for this project. These were played consecutively, so players were restricted from playing the second game until the first was completed, encouraging replays. Players were unable to access the form to enter the competition until both games were completed. Further, once the form was submitted, players were taken to a high-score board and informed that the winner would be selected only from the top players. This helped increase repeat visits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/wanted/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Bloody Valentine 3D</title>
		<link>http://www.bpulse.co.uk/portfolio/web/my-bloody-valentine-3d</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/my-bloody-valentine-3d#comments</comments>
		<pubDate>Thu, 15 Jan 2009 18:10:58 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[kiss]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=98</guid>
		<description><![CDATA[<p><a href="http://www.bpulse.co.uk/wp-content/uploads/2010/02/mbv.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2010/02/mbv-150x150.png" alt="" title="My Bloody Valentine 3D" width="100" height="100" class="alignleft size-thumbnail wp-image-97" /></a>
Simple advertorial with form and video.</p> <a href="http://www.bpulse.co.uk/portfolio/web/my-bloody-valentine-3d">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.bpulse.co.uk/wp-content/uploads/2010/02/mbv.png"><img src="http://www.bpulse.co.uk/wp-content/uploads/2010/02/mbv-216x300.png" alt="" title="My Bloody Valentine 3D" width="216" height="300" class="alignleft size-medium wp-image-97" /></a><br />
Simple advertorial with form and video.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/my-bloody-valentine-3d/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Camp Rock</title>
		<link>http://www.bpulse.co.uk/portfolio/web/camp-rock</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/camp-rock#comments</comments>
		<pubDate>Mon, 15 Sep 2008 13:51:24 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[ugc]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=76</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/camp-rock/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visa 2012</title>
		<link>http://www.bpulse.co.uk/portfolio/web/visa-2012</link>
		<comments>http://www.bpulse.co.uk/portfolio/web/visa-2012#comments</comments>
		<pubDate>Sun, 24 Aug 2008 18:25:55 +0000</pubDate>
		<dc:creator>Ben Parsons</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[bauer]]></category>
		<category><![CDATA[big city]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[olympics]]></category>
		<category><![CDATA[visa]]></category>

		<guid isPermaLink="false">http://www.bpulse.co.uk/?p=203</guid>
		<description><![CDATA[Campaign to reinforce VISA&#8217;s sponsorship of the 2008 Olympics. The site consisted of a design with a single form, and ran across all Big City Network websites.]]></description>
			<content:encoded><![CDATA[<p>Campaign to reinforce VISA&#8217;s sponsorship of the 2008 Olympics. The site consisted of a design with a single form, and ran across all Big City Network websites.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bpulse.co.uk/portfolio/web/visa-2012/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

