azurewebasp.net-coreazure-web-app-servicedeploying

Azure does not see Index.cshtml


I'm trying to publish my ASP.NET Core application on Azure service. This works, but when I try to use the application functionality, I get the message

Your App Service app is up and running.

Moreover, in my wwwroot folder I don't have any .html files. I only have an Index.cshtml file, which is located in the Views/Home-folder in my application, all another files are .css, .js, etc.

When I run the application in Visual Studio in Debug mode, immediately opens the page in browser that was generated from Index.cshtml. But after the application is published in Azure, this does not happen.

What can I do to make Azure see Index.cshtml?


Solution

  • AFAIK, a default route would be added to Configure method of your Startup.cs file as follows:

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
    

    I also created my .Net Core 2.0 MVC application to check this issue, it could work as expected on local side and my azure web app.

    Moreover, in my wwwroot folder I don't have any .html files.

    Views under Web Application and Web Apllication MVC would be compiled into {your-webapplication-assemblyname}.PrecompiledViews.dll, you could leverage ILSpy to check your DLLs.

    For your issue, I would recommend you clear the web content in your web app via KUDU, or modify the publish settings and choose Remove additional files at destination under File Publish Options, then redeploy your application to Azure Web App to narrow this issue.