This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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