I have recently started an Asp .Net Core
app. Later I wanted to integrate it with Angular, but first I wanted a mechanism that will 'replace' cshtml
with html
.
If I change extension from cshtml
to html
I get this
'InvalidOperationException: The view 'Index' was not found'.
Also I tried in Startup
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
but it also didn't work.
Optional is to integrating cshtml layout content with html pages, but I think this is impossible.
So, my question is, can I simply replace all cshtml with html?
Static files are typically located in the web root (wwwroot) folder.By default, that is the only place where we can serve up files directly from the file system.
1.create a
html
file inside (wwwroot) nameindex.html
2.install
Microsoft.AspNet.StaticFiles
package via NuGet3.Add
UseStaticFiles
inStartup.cs
under Configure methodeif you want to run Static Files outside
wwwroot
, then-your request like
http://<app>/StaticFiles/index.html
if you want
index.html
to be your default file, this is a feature that IIS has always had,thenhopefully it's help you. You can more information from this link.