Installing DotNetNuke 4.9.0 on Medium Trust WebserversWell, due to .NET hosting problems with running DotNetNuke under Medium trust, I decided to grab the latest version and try again from scratch. The site was previously plagued with "FileIOPermission" errors because of the way DotNetNuke was built for Medium Trust. Anyways, with a bit of finaggling, I was able to get the framework running again, this time with virtually no error messages. In this first post, I'm going to talk about how to set up DotNetNuke on a .NET 2.0 Medium Trust hosting environment that does not have AJAX installed, such as that of 1and1 or other similar shared hosting companies.
Now I know most of you probably don't care about how I came to the solution, so there's a quick summary of everything you need to get DNN 4.9.0 working on a 1and1 shared server at the bottom of this posting.
First off, I want to talk a bit about the problems I was having previously. I'm not fully sure if the cause was DotNetNuke, or 1and1, or just both in combination. In my previous version, the site was running relatively stable except that when the application stopped (automatically after inactivity), the first user to the site would then be welcomed with a FileIOPermission error. Subsequent page loads worked fine after that, but it's the first impression that makes the biggest impact, right? I believe the issue was that since I had my DNN installed on the root of my website, it would occasionally fail to see the path and try to access a file outside of my user space. This is a big no-no in Medium Trust.
My first attempt at reinstalling involved blowing away the database and files and just doing another reinstall, this time into the /content subfolder. I knew from previous experience that the installation seemed to often fail for me while installing the modules on the site, so I decided to try a different approach. I figured that file ownership would be a stronger tie than setting the permissions manually, so I decided to try unzipping the DNN files from within code, rather than using the WebFiles manager. This seemed to work better as I wasn't getting any errors once browsing the site after installation. I was ecstatic... Until I tried to acccess the host and portal settings. Then I got a similar but different FileIOPermission error. This time it was from a reflection call that was failing the FileIOPermission security check for a Validator control. Looking closely at the error I discovered a source was the script manager (using AJAX). After some research online, digging into the DNN source code, and messing around with .NET reflector, I was able to discover the source of the problem: within the .net framework itself. I didn't want to rewrite the validation controls for DNN some I came up with a simpler solution: disable AJAX. After that, the entire site has worked great, and I have yet to see an error.
So here goes... Everything you need to get DNN 4.9.0 working on a 1and1 shared hosting environment:
Using 1and1 WebFiles application (or your own host's file manager application):
- Create/Empty a subfolder to hold your DotNetNuke files
- Upload the DotNetNuke_04.09.00_install.zip file to the new folder. DO NOT unzip these files yet.
- Right click on the subfolder and select "Security." Set all permissions for the NETWORK SERVICE and IUSR_ accounts. Ensure that "Folder, subfolder, and files" is also selected in the dropdown. Click OK.
- Upload a copy of ZipManager (This is the extremely basic asp.net program I wrote to unpack a zip file) to the root of your website. You can download a copy from the Code Library.
- Unzip the ZipManager files now.
That's all we need to do from WebFiles, so you can close that window now. Keep your 1and1 control panel open, because you'll need it again after the DNN installation completes. Next we start the installation process:
- Browse to the zipmanager.aspx file on the root of your website. ex. www.programmersanonymous.net/zipmanager.aspx
- Select your DNN subfolder in the dropdown list.
- Click on the .zip file for the DotNetNuke files. They will immediately start to unpack in the same folder, so just wait for the page to finished loading. By unzipping the files this way, it ensures that the NETWORK SERVICE user is the owner of all of the DNN files and folders.
- Browse to your website path with the DNN files. ex. www.programmersanonymous.net/content The DotNetNuke Installation wizard should now come up.
- Follow the installation wizard using whatever settings your choose.
- When you get to your website, everything should appear to be working perfectly, until you log in as host and try to use one of the settings functions. Then the FileIOPermission security access check error will apear.
To fix this, we need to disable AJAX. Normally this would be done using Host Settings, which we currently can't access. So instead, we need to run a database script to disable it manually. Open your SQL admin tool and run the follow SQL script: (Be sure to update the table name if you added a table qualifier during installation)
INSERT INTO HostSettings (SettingName, SettingValue, SettingIsSecure)
VALUES('EnableAJAX', 'N', 0);
This script will manually insert the seting to disable AJAX and thus, the FileIOPermission error we have been receiving.
Go back into WebFiles and delete the ZipManager files, so that no one can come in and mess up your installation.
You can now navigate back to your website and viola! Everything should now be working superbly!