0

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?

Jan_V
  • 4,244
  • 1
  • 40
  • 64
deralbert
  • 856
  • 2
  • 15
  • 33
  • There's nothing wrong with Azure or ASP.NET Core. Both dynamic and static files are supported. The templates are used for years. Post your routing, configuration – Panagiotis Kanavos May 28 '18 at 10:44

4 Answers4

1

Are you finding index.cshtml in your web package? In case if you get index.cshtml in your final web package, you may need to add index.cshtml file type to the following in..

..YourAzureWebApp --> Application Settings --> Default Documents

enter image description here

Ashokan Sivapragasam
  • 2,033
  • 2
  • 18
  • 39
1

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.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35
  • Nice explanation, thanks. I really didn't configurate rooting correctly. Sorry for stupid mistake on my part! – deralbert May 28 '18 at 21:09
0

I found out what the problem was. There are two types of applications, as presented below in the picture: Web Application and Web Apllication MVC. I worked with the second type of application. When I selected the first type and published the application, Azure immediately found the required index.html. I just had to choose Web Application.

But why does not it work with the second type of application (Web Apllication MVC)? I still do not know the answer to this question.enter image description here

deralbert
  • 856
  • 2
  • 15
  • 33
  • That's not the issue at all. [Static files work with both templates](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.0&tabs=aspnetcore2x) - both templates use the *same* stack, ASP.NET Core, with different configurations. Where did you place your static files in each case? What does your configuration, routing look like? – Panagiotis Kanavos May 28 '18 at 10:40
  • Thanks for your comment. You're right. I, apparently, did not correctly set the routing or forgot that I made some changes in it. – deralbert May 28 '18 at 21:06
0

2 cents from my side as I just stuck for a while with this.

The problem was that yesterday I'd been playing around with deploying to Ubunut / Ngnix and today I decided to try Azure.

BUT I forgot to comment (disable) the following lines in my Startup:

//for nginx server
app.UseForwardedHeaders(new ForwardedHeadersOptions
         {
           ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
          });

and that costed me almost half of the day to find the issue.

I also put the routing in the following way

    app.UseStatusCodePages();

    app.UseAuthentication();

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

Now looks like it works on Azure :)

Fellow7000
  • 211
  • 1
  • 15