I have the following configuration:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDefaultFiles();
app.UseFileServer(new FileServerOptions
{
FileProvider = new EmbeddedFileProvider(typeof(Startup).Assembly, typeof(Startup).Namespace + ".WebApp"),
RequestPath = string.Empty
});
app.UseCors("CorsPolicy");
app.UseMvc(routes =>
{
routes.MapRoute(
name: "angular",
defaults: new {controller = "Angular", action = "Index"},
template: "{*url}");
});
}
My Angular project files are in the namespace MyNamespace.WebApp.
My AngularController and Startup classes are in the namespace MyNamespace
When I don't use MVC and access http://localhost:8000 it loads the index.html file in the WebApp folder. Now for all other requests (for example /action) I have mapped it to the AngularController, which looks as follows:
public class AngularController : Controller
{
public IActionResult Index() {
return View("/index.html");
}
}
I have debugged and verified that the request does come to AngularController.Index() and returns View("/index.html"). But after that I get a 500 Error. I'm guessing because it cannot find the view file.
How do I let MVC know to fetch the index.html file from the embedded files?
I've tried the following:
return View("~/index.html");
return View("index.html");
return View("~/../index.html");
return View("../index.html");
return View("~/WebApp/index.html");
return View("WebApp/index.html");
None of these work. Probably I've missed a step?
