I\'m using .net WebApi to expose different endpoints with JSON data. Now I need that an specific endpoint returns HTMLs pages. I have implemented it like this.
[
WebApi can serve static file.
So you just have to set the right link in your html file.
For example:
Your <img>
will be like this:
<img src="~/Content/img/email-icon.png" />
Finally I solved it. I added a static file server middleware using owin+katana.
I changed my startup class using this
public void Configuration(IAppBuilder application)
{
//Other webApi configuration
application.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/html/public"),
FileSystem = new PhysicalFileSystem(@"../../../MyProject/html/public"),
});
Now automatically all images scripts and files that are under public are served when my html page is requested via my webApi.
What does this code is to translate my http requests "/html/public" to my real file system path specified in PhysicalFileSystem.
Hope this help anybody.