I have simple .NET Core 2.2 Web App that I have deployed to Azure App Service. App contains a simple HomeController with Index Action and Index.cshtml file.
When I try to browse the page it gives me InvalidOperationException with message The view '~/src/Views/Home/Index.cshtml' was not found.
I have verified the path of the file and build action (Content), but due to some strange reason it cannot find the view. However surprisingly if I change the name of the View to Index1.cshtml it works.
Can anyone explain why this is happening?
public class HomeController : Controller
{
public IActionResult Index()
{
return View("~/src/Views/Home/Index.cshtml");
}
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
app.UseDeveloperExceptionPage();
app.UseStatusCodePages();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
I expect it to render the Index.cshtml instead it give me this: InvalidOperationException: The view '~/src/Views/Home/Index.cshtml' was not found. The following locations were searched: ~/src/Views/Home/Index.cshtml