Created
June 20, 2017 00:40
-
-
Save dcomartin/42885dd0dae8706f0d782252ed6d8c41 to your computer and use it in GitHub Desktop.
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