title: Serving clientaccesspolicy.xml through WCF Rest service, while hosting on IIS
body: <p>I am building a simple HTTP file server.<br>
  I have an asp.net web application that exposes a WCF service (FileService.svc).<br>
  The service contract is:</p>
  
  <pre><code>[OperationContract]
  [WebGet(UriTemplate = "/*")]
  Stream HandleFileRequest();
  </code></pre>
  
  <p>The service implementation is quite straightforward and basically I use :  </p>
  
  <pre><code>WebOperationContext.Current.IncomingRequest.UriTemplateMatch.RequestUri
  </code></pre>
  
  <p>To get the path of the file to return (A little parsing is required to extract it).  </p>
  
  <p>So for instance, when hosting the app locally on IIS , I can request a file from :
  <a href="http://localhost:65000/FileService.svc/someFolder1/someFolder2/someFile1.jpg" rel="nofollow">http://localhost:65000/FileService.svc/someFolder1/someFolder2/someFile1.jpg</a>  </p>
  
  <p>The problems starts when this request is made from inside a <strong>silverlight</strong> app. Silverlight searches the clientaccesspolicy file in <a href="http://localhost:65000/clientaccesspolicy.xml" rel="nofollow">http://localhost:65000/clientaccesspolicy.xml</a><br>
  The problem is that now, this request won't reach the service because FileService.svc is ommited from the url.</p>
  
  <p>(I want all the file requests to be handled by the WCF service in HandleFileRequest(), and not any other mechanism.)</p>
  
  <p>One solution I can think of is to use the <strong>URL Rewrite</strong> module of IIS 7.<br>
  Is this the right way to do this,  or there simpler solution to this ?</p>