I apologize in advance - this blog post is going to be all over the place. I haven't posted in a while, mainly because I've been engrossed in a personal programming project. Part of which includes a multithreaded web server I wrote over the weekend that I'm kind of proud of. My ShareDiscreetlyWebServer is single-threaded, because when I wrote it, I had not yet grasped the awesome power of the async and await keywords in C#. They're très sexy. Right now the only verb I support is GET (because it's all I need for now,) but it's about as fast as you could hope a server written in managed code could be.
Secondly, I just upgraded this site to Blogengine.NET v2.9. The motivation behind it was that today, I got this email from a visitor to the site:
I tried to leave you a comment but it didnt work.
Can you please go through steps you took to migrate your blog to Azure as I am interested in doing the same thing.
Did you set it up as a Azure Web Site or use an Azure VM and deployed it that way?
Are you using BlogEngine or some other blog publishing tool.
Wait, my comments weren't working? Damnit. I tried to post a comment myself and sure enough, commenting on this blog was busted. It was working fine but it just stopped working some time in the last few weeks. And so, I figured that if I was going to go to the trouble of debugging it, I'd just go ahead and upgrade Blogengine.NET while I was at it.
But first, to answer the guy's question above, my blog migration was simple. I used to host this blog out of my house on a Windows Server running in my home office. I signed up for a Server 2012 Azure virtual machine, RDP'ed to it, installed the IIS role, robocopy'd my entire C:\inetpub directory to the new VM, and that was that.
So version 2.9 so far is a little lackluster so far. They updated most of the UI to the simplistic, sleek "modern" look that's all the rage these days, especially on tablets and phones. But in the process it appears they've regressed to the point where the editor is no longer compatible with Internet Explorer 11, 10, or 9. (Not that it worked perfectly before either.) It's annoying as hell. I'm writing this post right now in IE with compatibility mode turned on, and still half of the buttons don't work. It's crippled compared to the version 2.8 that I was on this morning.
That's ironic that the developers who wrote a CMS entirely in .NET, in Visual Studio, couldn't be bothered to test it on any version of IE. Guess I'll wait patiently for version 3.0. Or maybe write my own CMS after I get finished writing the web server to run it on.
But even after the upgrade, and after fixing all the little miscellaneous bugs that the upgrade introduced, it still didn't fix my busted comment system. So I had to dig deeper. I logged on to the server, fired up Process Monitor while I attempted to post a comment:
w3wp.exe gets an Access Denied error right there, clear as day. (Thanks again, ProcMon.)
If you open the properties of w3wp.exe, you'll notice that it runs in the security context of an application pool, e.g. "IIS APPPOOL\Default Web Site". So just give that security principal access to that App_Data directory. Only one problem...
No right-clicking our way out of this one. Of course we could have done this with cacls.exe or something, but you know I'm all about the Powershell. So let's do it in PS.
$Acl = Get-Acl C:\inetpub\wwwroot\App_Data
$Ace = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS APPPOOL\Default Web Site", "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
Set-Acl C:\inetpub\wwwroot\App_Data $Acl
Permissions, and commenting, are back to normal.