<?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>PeterKellner.net &#187; Page Handlers</title>
	<atom:link href="http://peterkellner.net/category/page-handlers/feed/" rel="self" type="application/rss+xml" />
	<link>http://peterkellner.net</link>
	<description>Microsoft Focussed, JavaScript (ExtJS, SenchaTouch &#38; Windows 8 Metro)</description>
	<lastBuildDate>Tue, 07 Feb 2012 21:14:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to do URL Rewrites with ASP.NET 2.0 3.0 3.5 on IIS6 and IIS7 and What is Wild Card Mapping</title>
		<link>http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/</link>
		<comments>http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 03:19:02 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[How Things Work]]></category>
		<category><![CDATA[Page Handlers]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/</guid>
		<description><![CDATA[<p>A Step by step tutorial on how to use WildCard Mapping for processing URL requests.  It includes how to set it with IIS6 and IIS7.  It also discusses the theory behind how it works and talks about a great open source packaged called URLRewriter.Net.  Basically, how to resolve http://mydomain.com/Home to http://mydomain.com/HomeSite/Home.aspx which looks so much nicer.</p>]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>  <p>Over the past several years I&#8217;ve found myself running into the same problem over and over so I thought I&#8217;d blog the solution so at least I don&#8217;t waste time figuring it out again.&#160; So, when do you need this?&#160; The answer for me is that I want to be able reference a web site without having to expose the underlying site structure.&#160; For example, on the home page of my business, I want people to be able to type <a href="http://73rdstreet.com/Home">http://73rdstreet.com/Home</a> and be taken to <a title="http://www.73rdstreet.com/HomeSite/Home.aspx" href="http://www.73rdstreet.com/HomeSite/Home.aspx">http://www.73rdstreet.com/HomeSite/Home.aspx</a>. </p>  <h2>The Symptom</h2>  <p>You may see errors that say something like: </p>  <p>Server Error in Application &#8230; HTTP Error 404.0 &#8211; Not Found</p> <span id="more-142"></span>  <p><strong>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</strong></p>  <p><a href="http://msdn.microsoft.com/en-us/library/system.web.httpapplication.maprequesthandler.aspx">MapRequestHandler</a> StaticFile</p>  <p>And the screen may show something like this.</p>  <p><a href="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/x.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="x" src="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/x_thumb.png" width="537" height="397" /></a></p>  <p>If this happens, read on. </p>  <h2>Theory</h2>  <p>The first thing to understand is that <a href="http://www.microsoft.com/WindowsServer2003/IIS/Default.mspx">IIS</a> by default will pass to the asp.net process only the requests that have a certain file extension.&#160; That is, <a href="http://www.eggheadcafe.com/articles/20030113.asp">aspx,ashx</a>,etc.&#160; Basically, only file extensions that have a handler defined for them to be processed by.&#160; Other URL&#8217;s that don&#8217;t meet the criteria are not passed to IIS.&#160; This includes no file extension at all.&#160; There is a good reason for this.&#160; One, it makes processing of things like images (jpg&#8217;s, gif&#8217;s, etc.) faster because they do not every have to be processed through the asp.net worker process.&#160; Secondly, it lowers the exposure of the asp.net worker process so that it is less likely to be compromised. </p>  <p>So, the first thing that has to be done is to tell IIS to pass all requests through using something called Wild Card Mapping.&#160; Then, once this is done, the request comes through to the asp.net worker process regardless of what it is.&#160; As we know, the place that we would have to process this is an <a href="http://msdn.microsoft.com/en-us/library/9b9dh535.aspx">HttpModule</a>.&#160; The reason is that since it&#8217;s not a page yet, we have no idea what to do with it.&#160; Basically modules let you tap into the request at different stages.&#160; To do the rewrite from ../Home to ../HomeSite/Home.aspx we want to tap into the <a href="http://msdn.microsoft.com/en-us/library/ms227673.aspx">Application_BeginRequest</a> event.&#160; The Context.<a href="http://msdn.microsoft.com/en-us/library/ms223300.aspx">RewritePath</a> method is called at that point to force a new path based on what we want (hopefully not hard coded).</p>  <p>After the ReWritePath is set, the page is processed as if is going to the correct page.</p>  <h2>How To Set Wild Card Mapping in IIS6</h2>  <p>To Set Wild Care Mapping in IIS6 you need to do the following.</p>  <p>Run inetmgr and navigate to the Properties page of the website you want to set.</p>  <p><a href="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/test.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="test" src="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/test_thumb.jpg" width="272" height="332" /></a>&#160;</p>  <p>Then, from the properties page, click the Configuration button as shown below.</p>  <p><a href="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/t.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="t" src="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/t_thumb.jpg" width="280" height="281" /></a></p>  <p>Then, press the insert button on the configuration screen and see the following screen and then click on the insert button.</p>  <p><a href="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/t6.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="t[6]" src="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/t6_thumb.jpg" width="288" height="320" /></a></p>  <p>Now, insert your asp.net isapi dll.&#160; On my system, the file is here:&#160; C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll.&#160; Make sure to uncheck the box &quot;Verify that file exists&quot;.</p>  <p><a href="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/t9.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="t[9]" src="http://www.peterkellner.net/FilesForWebDownload/How.0plusonIIS6andIIS7andWhatisWildCardM_10C46/t9_thumb.jpg" width="430" height="126" /></a></p>  <p>That&#8217;s it! Now, all requests will be processed through you asp.net pipeline so you will be able to intercept anything on the URL you want.&#160; Be careful though, you may get more than you ask for! </p>  <h2>How To Set Wildcard Mapping in IIS7</h2>  <p>In IIS7 things are a little different.&#160; First thing you need to do is unlock the config section &quot;handlers&quot;. You do this by bring up a DOS prompt and entering the command: </p>  <p>C:\Windows\System32\inetsrv&gt;appcmd.exe unlock config /section:system.webserver/handlers</p>  <p>Then, you can set your wildcard handler in your web.config file as follows.</p>  <p>Now, the default handlers will be executed in your web.config file, and of course, all the defaults for that are in the chain of files that inherits from.&#160; For more details on that, see this FAQ: <a href="http://forums.asp.net/p/1117776/1736929.aspx">Configuration Files FAQs (web.config, machine.config&#8230;)</a>.</p>  <p>You may need to add the wildcard mapper handler to your web.config.&#160; To do this, you would put the following in your web.config</p>  <pre class="csharpcode"><span class="kwrd">&lt;?</span><span class="html">xml</span> <span class="attr">version</span><span class="kwrd">=&quot;1.0&quot;</span> <span class="attr">encoding</span><span class="kwrd">=&quot;UTF-8&quot;</span>?<span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">system.webServer</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">handlers</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">name</span><span class="kwrd">=&quot;WildCard&quot;</span> <span class="attr">path</span><span class="kwrd">=&quot;*&quot;</span> <span class="attr">verb</span><span class="kwrd">=&quot;*&quot;</span> <span class="attr">type</span><span class="kwrd">=&quot;sampletype&quot;</span> <span class="attr">resourceType</span><span class="kwrd">=&quot;Unspecified&quot;</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">handlers</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">system.webServer</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>

<p>Now, you should be set. See the next section for a good method for actually doing the remapping, which is why we went down this path in the first place.</p>

<h2>Implementing a URL ReWriter for Mapping ../Home to ../HomeSite/Home.aspx</h2>

<p>So, as discussed in the theory section above, you could write your own code to map what you want to where you want it.&#160; You could put in your global.asax some code for the Application_BeginRequest and make a big case statement for everything you want to do.&#160; Well, as we know, that would give your code a bad smell and we don&#8217;t want that because soon, you will find yourself using cut and paste and other problematic crutches.</p>

<p>So, to avoid all that, and do what <a href="http://weblogs.asp.net/scottgu">Scott Guthrie</a> suggests, use the open source package <a href="http://urlrewriter.net/">UrlRewriter.NET</a>.&#160; It&#8217;s light-weight and configurable through a small section in your web.config. Before putting in the what to do, here are the steps to make UrlRewriter work in a very simple way (the way I use it on my <a href="http://73rdstreet.com/Home">company home page</a>.</p>

<p>In your &lt;System.web&gt; of your web.config place a definition for a new config section where you will put your rewrites</p>

<div class="csharpcode">
  <pre class="alt"><span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span><span class="html">configSections</span><span class="kwrd">&gt;</span></pre>

  <pre class="alt">      <span class="kwrd">&lt;</span><span class="html">section</span> <span class="attr">name</span><span class="kwrd">=&quot;rewriter&quot;</span> <span class="attr">requirePermission</span><span class="kwrd">=&quot;false&quot;</span> </pre>

  <pre>        <span class="attr">type</span><span class="kwrd">=&quot;Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter&quot;</span><span class="kwrd">/&gt;</span></pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>&#160;</p>

<p>Then, put the module that actually does the work of the rewrite as described in the theory section above</p>

<div class="csharpcode">
  <pre class="alt">&lt;system.web&gt;</pre>

  <pre>   &lt;httpModules&gt;</pre>

  <pre class="alt">     &lt;add name=<span class="str">&quot;UrlRewriter&quot;</span> </pre>

  <pre>           type=<span class="str">&quot;Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter&quot;</span> /&gt;</pre>

  <pre class="alt">     &lt;/httpModules&gt;</pre>

  <pre>       ..</pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>Then, further down in your web.config put</p>

<div class="csharpcode">
  <pre class="alt"><span class="kwrd">&lt;</span><span class="html">system.webServer</span><span class="kwrd">&gt;</span></pre>

  <pre>  <span class="kwrd">&lt;</span><span class="html">validation</span> <span class="attr">validateIntegratedModeConfiguration</span><span class="kwrd">=&quot;false&quot;</span><span class="kwrd">/&gt;</span></pre>

  <pre class="alt">  <span class="kwrd">&lt;</span><span class="html">modules</span><span class="kwrd">&gt;</span></pre>

  <pre>    <span class="kwrd">&lt;</span>add name=&quot;UrlRewriter&quot;</pre>

  <pre class="alt">         type=&quot;Intelligencia.U</pre>
</div>

<div class="csharpcode">&#160;</div>

<div class="csharpcode">And, Finally to actually do the redirect you need to put a new &lt;rewriter&gt; tag with a list of redirects in it.</div>

<div class="csharpcode">&#160;</div>

<div class="csharpcode">
  <pre class="alt"><span class="kwrd">&lt;</span><span class="html">rewriter</span><span class="kwrd">&gt;</span></pre>

  <pre>  <span class="kwrd">&lt;</span><span class="html">rewrite</span> <span class="attr">url</span><span class="kwrd">=&quot;~/Home&quot;</span> <span class="attr">to</span><span class="kwrd">=&quot;~/pages/Home.aspx&quot;</span><span class="kwrd">/&gt;</span></pre>

  <pre class="alt"><span class="kwrd">&lt;/</span><span class="html">rewriter</span><span class="kwrd">&gt;</span></pre>
</div>
<style type="text/css">


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>That&#8217;s it!&#160; You are done.&#160; Hope this helps, or at least helps me the next time I&#8217;m searching for the same problem (for the 4th time at least).</p>

<p>References:</p>

<ul>
  <li><a title="http://devtalk.dk/2007/03/19/Wildcard+Mapping+And+URL+Rewriting+On+IIS7.aspx" href="http://devtalk.dk/2007/03/19/Wildcard+Mapping+And+URL+Rewriting+On+IIS7.aspx">http://devtalk.dk/2007/03/19/Wildcard+Mapping+And+URL+Rewriting+On+IIS7.aspx</a> </li>

  <li><a title="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx">http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx</a> </li>

  <li><a title="http://urlrewriter.net/" href="http://urlrewriter.net/">http://urlrewriter.net/</a> </li>

  <li><a title="http://forums.asp.net/t/1240344.aspx" href="http://forums.asp.net/t/1240344.aspx">http://forums.asp.net/t/1240344.aspx</a> </li>

  <li><a title="http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx" href="http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx">http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx</a> </li>

  <li><a title="http://professionalaspnet.com/archive/2007/07/27/Create-an-HttpModule-to-Process-Wildcard-Extension-Mapping-in-ASP.NET.aspx" href="http://professionalaspnet.com/archive/2007/07/27/Create-an-HttpModule-to-Process-Wildcard-Extension-Mapping-in-ASP.NET.aspx">http://professionalaspnet.com/archive/2007/07/27/Create-an-HttpModule-to-Process-Wildcard-Extension-Mapping-in-ASP.NET.aspx</a> </li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/08/24/urlrewrite-with-aspnet-urlrewriter-wildcard-mapping-iis6-iis7/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Display Images with IIS7 in Vista or Windows 2008</title>
		<link>http://peterkellner.net/2008/04/01/iis7imageproblem/</link>
		<comments>http://peterkellner.net/2008/04/01/iis7imageproblem/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 12:38:59 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Page Handlers]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2008/04/01/iis7imageproblem/</guid>
		<description><![CDATA[<p>How to solve problem off image not appearing in iis7.  css,gif's, etc.</p>]]></description>
			<content:encoded><![CDATA[<p>So, this may seem simple, but for an hour I wrestled with displaying images on IIS7 with vista.&#160; ASP.NET worked fine, but no static files, css, jpg&#8217;s, gif&#8217;s or anything.&#160; Just unformatted text.</p>  <p>Turns out when I added the web server in vista, I forgot to check the Static Content checkbox under World Wide Web Services / Common Http Features.</p> <span id="more-107"></span>  <p>Hope this finds you if you are having the same problem.</p>  <p><a href="/wp/wp-content/uploads/2008/04/webconfig.jpg"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="webconfig" src="/wp/wp-content/uploads/2008/04/webconfig-thumb.jpg" width="333" height="297" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2008/04/01/iis7imageproblem/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Display Images with the Silverlight Downloader in Alpha 1.1</title>
		<link>http://peterkellner.net/2007/07/03/silverlightdownloader/</link>
		<comments>http://peterkellner.net/2007/07/03/silverlightdownloader/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 04:38:34 +0000</pubDate>
		<dc:creator>Peter Kellner</dc:creator>
				<category><![CDATA[ASP.NET 2.0]]></category>
		<category><![CDATA[Page Handlers]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://peterkellner.net/2007/07/03/silverlightdownloader/</guid>
		<description><![CDATA[<br /><p>This article gives you a way to download images from remote servers on different domains using the downloader object of Silverlight.  Without this, you can not easily keep track of when images are downloaded to your Silverlight Application and deal with that event.  You simply can set the source tag and the image arrives when it arrives.</p>]]></description>
			<content:encoded><![CDATA[<p><strong>From Non-Local Servers Asynchronously</strong></p>  <p>This issue has come up several times for me.&#160; That is, you have an image&#160; url you want to display in your silverlight .net 1.1 application that comes from&#160; some foreign server.&#160; That is, you want this to work:&#160; (and of course    <br />it does not).</p>  <h2>The Problem</h2>  <p><img alt="does not work" src="http://peterkellner.net/misc/downloader1.jpg" /></p> <span id="more-67"></span>  <p>Even though, you can do this:</p>  <p><img alt="does not work" src="http://peterkellner.net/misc/downloader2a.jpg" /></p>  <p>There seems to be a subtle difference having to do with cross domain security&#160; that I just don&#8217;t get but since it&#8217;s there, we have to deal with it.</p>  <h2>The Solution</h2>  <p>So first, why do you even care.&#160; Why not just do the one that works?&#160; Well, the answer is that you want to be able to deal with what happens while an image is being downloaded.&#160; My particular problem has to do with what happens when you bring up a picture in a modal dialog type thing.&#160; That is, you click on a small thumbnail, and a larger ones comes up.&#160; In my case, I&#8217;m getting the image url from a web service so I don&#8217;t have the luxury of opening it locally.&#160; I have to use a foreign (remote) url.&#160; And, the reason I don&#8217;t want to open it by simply setting the source tag is that I&#8217;m    <br />reusing a control.&#160; This means that I&#8217;m simply hiding it and unhiding it. If I just set the source and unhide it, the wrong image comes up.&#160; That is, the one from the previous request. Then, a few seconds later, the correct image     <br />comes up.&#160; Bad.</p>  <p>We really want to use the Downloader object.&#160; A very cool control, but not if it doesn&#8217;t work cross domain IMHO.</p>  <p>The work around for this is to write a http handler that runs in your local asp.net project that you pass the url you want to display. Then, that web service turns around, calls the cross domain server, gets the image and returns it to your Downloader object.&#160; Simple in concept, but the devil is in the details.&#160; How, for example to you pass a url (that may include all kinds of stuff like &amp;&#8217;s to a local web service.&#160; The answer is encode it!&#160; Then decode it at the web service.&#160; I&#8217;m sure you all can whip that up quickly, but since I did already, why bother.&#160; I&#8217;m going to paste the code below with brief explanations to help.&#160; Here goes:</p>  <h3>The Silverlight UserControl That Calls the web service</h3>  <p>The way I did the code in the silverlight control is to encode the real URL I want.&#160; That is the one cross domain.&#160; I think build a URL that calls my local web service passing the parameter encoded as a base64 value as one of    <br />the url parameters.&#160; I&#8217;m using a property in my usercontrol to set this value just because that&#8217;s kind of convenient.&#160; Here is what the code looks like:</p>  <p><img alt="does not work" src="http://peterkellner.net/misc/downloader3.jpg" /></p>  <p>Just to give you a hint of what the might look like, in my case, this is what it is:</p>  <p><a href="http://localhost:49803/WebService/DisplayImage.ashx?URL=aHR0cDov...NDE0NzU2LkpQRw==&amp;Width=400">     <br />http://localhost:49803/WebService/DisplayImage.ashx?URL=aHR0cDov&#8230;NDE0NzU2LkpQRw==&amp;Width=400</a></p>  <p>(I put a bunch of &#8230;&#8217;s in the middle, but it was longer than that originally)</p>  <p>Silverlight is kind of limited on conversion functions so I had to write this little one called EncodeTo64 which is pasted below.&#160; I&#8217;m sure there are better ways to do it, but this one works.</p>  <p><img alt="does not work" src="http://peterkellner.net/misc/downloader5.jpg" /></p>  <p>And, don&#8217;t forget that you need to have the completed event code in your silverlight side to handle setting the source tag when the image is fully downloaded.&#160; Here is that function.</p>  <p><img alt="does not work" src="http://peterkellner.net/misc/downloader6a.jpg" /></p>  <h3>The Http Handler (DisplayImage.ashx file)</h3>  <p>To make all this come to live, you need an http handler that will make the call to the cross domain server.&#160; Below is that code.&#160; I added an extra parameter for width so that if you know the image you need is smaller than the one across the internet, you can just get downloaded what you need.&#160; Here is the code for the handler:</p>  <p><img alt="does not work" src="http://peterkellner.net/misc/downloader7.jpg" /></p>  <p>&#160;</p>  <h2>Conclusion</h2>  <p>I&#8217;m guessing that this problem will go away in the next alpha or beta release of Silverlight .net.&#160; In the mean time, this works very well for me and hopefully will for you also.&#160; I don&#8217;t have this in a good sample application and really just wanted to get it posted because I know others were having the same problems.&#160; If someone goes through and makes a good demo of this, please post a comment with the code for others to download.</p>  <p>Thanks for reading, and best of luck with your Silverlight Development!</p>]]></content:encoded>
			<wfw:commentRss>http://peterkellner.net/2007/07/03/silverlightdownloader/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 6/13 queries in 0.007 seconds using disk

Served from: peterkellner.net @ 2012-02-10 04:33:40 -->
