1

I am just about to launch an Azure Web App (aka Azure Web Sites) and have a quick question.

I've noticed there was a pretty significant lag on using the site when I publish my site from Visual Studio. Each page(/controller?) appeared to be compiling only when it was first accessed so it made the site feel very slow at least for a few minutes. I want to avoid that so I am used the "Precompile" option when I Build and Publish from VS. This seems to work and, although there is still some initial lag after publishing, it's much better than it was.

My question is this: Because this is a new site and we are constantly adding functionality and fixing bugs, I would like to have a section on my main _Layout page which I can quickly edit with a notification (ie. "Site will go down in 15 minutes for maintenance."). The problem is that I don't want to go through the whole Build/Publish process to get that content up to the site. Is there a way that I can include some file / content (page_alert.html) in my _Layout.cshtml page that can be edited in something like the Azure App Service Editor? Because of the precompiled nature of the site, all my .cshtml files now just say "This is a marker file generated by the precompilation tool, and should not be deleted!" in the App Service Editor.

Thanks!

Mike Smith
  • 618
  • 10
  • 27

2 Answers2

1

When you choose the Precompile option, you can also check 'Allow precompiled site to be updatable'. That will then allow you to update individual .cshtml files which will be compiled on the fly, while the rest is still precompiled.

See doc for details.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • Thanks for the reply. I tried that. However, the initial 'startup' delay came back and was nearly as long as it was when I wasn't precompiling. The first time the pages were accessed, there was a significant delay (30 sec). The only way I could find to eliminate the delay was to uncheck this option. – Mike Smith Sep 10 '17 at 20:53
  • That's puzzling, and I can't explain it. You may also want to give [RazorGenerator](https://github.com/RazorGenerator/RazorGenerator) a try. – David Ebbo Sep 10 '17 at 20:55
  • Maybe the reason is that every page *depends* on the layout page. So if you change that, it invalidates everything else and you lose all the benefits. – David Ebbo Sep 10 '17 at 20:56
0

I think I found a solution that will work from another SO posting.

https://stackoverflow.com/a/14634578/1359788

@Html.Raw(File.ReadAllText(Server.MapPath("~/content/somefile.html")))

I can edit that somefile.html in the App Service Editor and it works

Mike Smith
  • 618
  • 10
  • 27