Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.