Frank La Vigne

Fear and Loathing in .NET

MVP Logo
Tablet PC MVP

Social Networks

Subscription Options

Add to Google

Subscribe in Bloglines

My Links


Post Categories

Archives

Image Galleries

Cached @ 9/3/2010 2:44:38 AMControl ASP.skins_marvin3_controls_archivelinks_ascx

GamerTag

Dev Community Events

Blog Stats

Cached @ 9/3/2010 2:44:38 AMControl ASP.skins_marvin3_controls_blogstats_ascx  

News


Blog Roll

Favorite Sites

Gadget Blogs

Tablet PC Links

Cached @ 9/3/2010 2:44:38 AMControl ASP.skins_marvin3_controls_categorydisplay_ascx

Silverlight 2 Cross Domain Web Proxy Utility

Ever since Ian Griffiths' post on a bug in Cross Domain web access and my own experiments, I decided to create a web proxy class that creates web request to a URI from a remote site and passes the data back to the client.

The code preserves Mime Types, so it works with images/media files as well as text based files.

In other words, you can access any file type on the web, regardless of that site's Cross Domain access policy.

Just place this ASPX page on a site whose Cross Domain policy you can control.

Here's the main piece of the code:

// Make new WebClient
WebClient webClientRequest = new WebClient();

// Download data from URI
byte[] requestByteArray = webClientRequest.DownloadData(sourceUriString);

// Match the Mime Types
string contentType = webClientRequest.ResponseHeaders["Content-type"].ToString();
Response.ContentType = contentType;

// Copy the Streams
int requestByteArrayLength = requestByteArray.GetLength(0);
Response.OutputStream.Write(requestByteArray, 0, requestByteArrayLength);
Response.OutputStream.Close();

// Exit the Page
Response.End();

 

[Download Source Code 3k]

posted on Tuesday, March 18, 2008 1:51 PM

============ Debug Build ============
Dottext Version: 0.95.2004.102
Machine Name: IIS07902
.NET Version: 2.0.50727.3053
No User
============ Debug Build ============