1

I've found this answer coherent to this old article but both don't work. Thus I'm here to ask a new solution that works with VS2017. I'll explain more in detail: First time you define a virtual directory (as "/site1" and physical folder "site\site1") and try to publish from VS2017, you receive an error (cannot write into the specified path) and cannot publish. Then if you enter into the console (from portal.azure.com) and manually create the folder under d:\site with "md site1"), the publish process works (and lot of files have been created under the new folder) and finishes with a "1 successful...", BUT when you browse to the new ..../site1 you receive the following error message: "The page cannot be displayed because an internal server error has occurred."

Cannot find anything around on the web to solve this specific error (in one old doc they were saying it is due to separate git repos for the 2 projects (in the same solution), one targeting to the root folder and another one targeting the virtual directory, but I cannot understand why different source controls should make troubles in production when publishing through VS2017)...

Anybody know how to solve this?

UPDATE as requested by David Ebbo: I think the problem is a configuration problem Azure side (the other articles don't explain you have to create a physical folder through console when defining virtual directories) and/or runtime error (when the physical folder is created the publishing process from VS2017 works and it is completed successfully).

Here are more details to understand the context: 1) the Visual Studio Solution contains 2 project: one "main project" (empty .NET Core project with "Hello world!") with publish profile targeting the root folder of the Azure website + another "child project" (standard MVC Core.NET template project with no customization) with publish profile targeting the same Azure site with "/site1" added to the tail of "site name" and "site url". 2) If I try to publish the child project to the root folder of the site, everything works fine (but of course I overwrite the "main project"), thus it's not a code/version problem. 3) Going through console, I can see the folder d:\home\site\site1 contains files "similar" to the ones present in d:\home\site\wwwroot for the main project.

Marco
  • 11
  • 1
  • 5
  • 1
    I think the question is not clear enough about whether your issue is VS Publishing related (i.e. files not making it in the right place), or runtime related (files are there but don't run as you expect). Please see [this post](https://github.com/projectkudu/kudu/wiki/Deployment-vs-runtime-issues) and rephrase accordingly. – David Ebbo Jun 11 '17 at 22:36

1 Answers1

6

First time you define a virtual directory (as "/site1" and physical folder "site\site1") and try to publish from VS2017, you receive an error (cannot write into the specified path) and cannot publish.

I create a virtual directory and publish a web application from VS 2017. I can't reproduced your issue. Here are my detail steps.

Step 1. Create a virtual directory from Azure portal. Please make sure you have checked the [Application] checkbox and clicked the [Save] button.

enter image description here

Step 2. Deploy a web application using VS 2017. Search and choose an App Service from VS deploy window.

enter image description here

Step 3. Click settings button to configure the virtual directory.

enter image description here

Step 4. Change the site name and destination URL based on the virtual directory name.

enter image description here

Step 5. Click publish button to publish the web application.

After publish my web application, I can view the web application successfully from following URL.

http://mysitename.azurewebsites.net/site1

Please check whether there are any differences between my steps and yours.

when you browse to the new ..../site1 you receive the following error message: "The page cannot be displayed because an internal server error has occurred."

If it caused by your web application, I suggest you change customErrors mode property as 'Off' to view detail error message.

<system.web>
    <customErrors mode="Off" />
</system.web>

Edit 2017/6/13 10:37

The issue is related to ASP.NET Core. When I publishing a ASP.NET Core web application, I can reproduce the issue.

We can find the reason from this official document.

When adding applications to an IIS Site's root application, the root application web.config file should include the section, which adds the ASP.NET Core Module as a handler for the app. Applications added to the root application shouldn't include the section. If you repeat the section in a sub-application's web.config file, you will receive a 500.19 (Internal Server Error) referencing the faulty config file when you attempt to browse the sub-application.

To solve this, we need to edit the web.config file in this sub directory. We can do it using kudu console. Click the edit button in front of web.config file.

enter image description here

Remove the aspNetCore handler and click save.

enter image description here

Amor
  • 8,325
  • 2
  • 19
  • 21
  • Hi Amor, yes exactly the same steps, but if I don't manually create a physical folder for site1 in d:\home\site\site1, the publish doesn't work. This is the first difference... you don't create a physical folder, I have to. Another thing: I don't have any file containing the section... do I have to add that block inside the web.config of the site1 project? where exactly please? – Marco Jun 12 '17 at 23:28
  • Anyway, please remember that when I deploy the "site1" app inside the root folder "/" (mapped on d:\home\site\wwwroot) it starts perfectly, thus I don't think this problem ("The page cannot be displayed because an internal server error has occurred." error message) can be related to the code. – Marco Jun 12 '17 at 23:39
  • The issue is related to ASP.NET Core, I modified my reply to add the solution. – Amor Jun 13 '17 at 02:47
  • Very good! It works but... web.config file is replaced with the "wrong" one anytime I make a new publish. How can I keep the right web.config file if I cannot see it inside the project at all (in VS2017)? Thanks – Marco Jun 13 '17 at 21:12
  • You could add a web.config file to your ASP.NET Core web application. If your project contains a configuration file. Azure Web App will not create a default configuration file for you. – Amor Jun 14 '17 at 06:16
  • Sorry Amor, but seems not working. I added into the root folder of my "child project" site1 a web.config file with content copied&pasted from the one working on Azure, already edited in Kudu console, then set property to "copy always content". Now the web.config is published with the other files BUT browsing /site1 shows always the error message. If I go into the web.config file through kudu console, the web.config has been changed while publishing: the file is the one coming from VS2017 but it has the wrong-row added again and a comment-row added at the end of the file (with the ProjectGuid) – Marco Jun 14 '17 at 22:17
  • The web.config file will be changed if you run your application. Please check whether the config file is changed when deploying your asp.net core application. – Amor Jun 15 '17 at 09:10
  • Sorry Amor, how can I check when the file is changed (runtime or deploy-time) if pushing the PUBLISH button in VS2017 both the actions are executed one next the other? In kudu console I can see the date-hour changes once only but immediately after the change a new tab opens with the error message inside, thus I cannot understand if it's a delay in the kudu console to be refreshed of something different. Anyway, if I edit the file inside the kudu console it stay correct also when restarting the webapp service. Thanks for your support. – Marco Jun 15 '17 at 22:27
  • @Marco - Did you ever find a solution to this? ( web.config being overwritten / modified on publish / run-time ) I'm seeing the same issue when deploying to a virtual directory in azure and I'm having to manually edit the web.config each time to remove the aspNetCore handler. – Pj. Sep 21 '17 at 10:09
  • 1
    @Pj yes I've found a solution: no deployment have to stay in the root virtual folder! I used the kudu console CMD to completely clear the folder d:\home\site\wwwroot and any subfolder. No webapp released in the virtual / folder, but only into the /site1 /site2 etc. This way no more web.config files have been generated inside the subfolders. – Marco Sep 23 '17 at 16:06
  • @Marco - So you just set up multiple virtual directories and just deploy to them? Wow, thanks - I'll give it a try! – Pj. Sep 24 '17 at 07:37
  • @Pj Yes. In order to never deploy in the root virtual folder, I downloaded the deployment profile from Azure portal and edited using notepad++ changing site name and destination folder. The secret was leaving the root folder completely empty. That's it. – Marco Sep 25 '17 at 04:55