Skip to content

Instantly share code, notes, and snippets.

@JayDouglass
Created June 1, 2011 04:43
Show Gist options
  • Save JayDouglass/1001798 to your computer and use it in GitHub Desktop.
Save JayDouglass/1001798 to your computer and use it in GitHub Desktop.
Output html from WCF REST service using stream
public Stream GetPage()
{
var page = Properties.Resources.Status; // page from resources
// Get site relative base url for use in javascript ajax requests
var baseUrl = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BaseUri.AbsolutePath;
page = page.Replace("%BaseURL%", baseUrl);
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(page));
WebOperationContext.Current.OutgoingResponse.ContentType = "text/html";
return stream;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment