Skip to content

Instantly share code, notes, and snippets.

@msarchet
Created January 16, 2014 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msarchet/8461623 to your computer and use it in GitHub Desktop.
Save msarchet/8461623 to your computer and use it in GitHub Desktop.
public class LayoutController : ApiController
{
[HttpGet]
[Route("", Name = "Index")]
public async Task<HttpResponseMessage> LayoutHtml()
{
var path = HttpContext.Current.IsDebuggingEnabled
? HttpContext.Current.Server.MapPath("~/App/Views/Index.html")
: HttpContext.Current.Server.MapPath("~/App/View/Index_Release.html");
var file = await File.OpenText(path).ReadToEndAsync();
var responseMessage = this.Request.CreateResponse(HttpStatusCode.OK);
var content = new StringContent(file);
responseMessage.Content = content;
responseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return responseMessage;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment