Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created June 20, 2017 00:40
Show Gist options
  • Save dcomartin/42885dd0dae8706f0d782252ed6d8c41 to your computer and use it in GitHub Desktop.
Save dcomartin/42885dd0dae8706f0d782252ed6d8c41 to your computer and use it in GitHub Desktop.
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace EmbeddedResource.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
// GET api/values
[HttpGet, Produces("application/json")]
public async Task<string> Get()
{
var assembly = Assembly.GetEntryAssembly();
var resourceStream = assembly.GetManifestResourceStream("EmbeddedResource.Data.fakedata.json");
using (var reader = new StreamReader(resourceStream, Encoding.UTF8))
{
return await reader.ReadToEndAsync();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment