8. September 2010 08:34
I hate the Web Site project template offered by Visual Studio. I find it very black magic like. There are just too many things that don't follow my C# back end Distributed Architecture roots so I'm much more comfortable in the Web Application Project scenario. When I added this blog to my web site - i went with blogengine.net because it was the best open source blog engine I could find. It is a great engine - kudos to the authors.
Back to my issue... Need Web Application Project. Problem - BlogEngine is not one of those. Solution: Convert it! Here's how:
Download the lastes source code you are comfortable with. You'll get the following folders:
There are others but we don't care about them.
Step 1: Rename the BlogEngine.NET folder to BlogEngine.Net.save (this is only necessary if you want to keep BlogEngine.NET as the web app's folder
Step 2: Create a new empty Web Application Project
- Open Visual Studio and create a new Project (not a web site!) and select ASP.NET Web Application
- Don't use .NET 4 Framework (if you're using VS 2010) - this will save you some clean up work
- Keep track of where you create this project and what you call it...
- Remove all the created items from the project
- If you used .NET 3.5 framework, you should be deleting App_Data, Scripts, Default.aspx, and Web.config
- Close and save your solution
- <- delete the circled files/folders...
Step 3: Copy the BlogEngine.NET files to the new web application folder
- Copy all the files from the original BlogEngine.NET folder
- Paste them into the project folder created in step 2
- skip the bin folder if you've already run the Web Site...
Step 4: Re-open the new web application and add existing files
- Open the web application you created in step 2
- Select the "Show All Files" button in the solution explorer toolbar
- Select all the files and/or folders that show up except for bin and obj - right-click|Include In Project
- This may take a few minutes
Step 5: Convert content to Web Application
- Right click on the Project (not a single file or folder within the project) and select Convert to Web Application
- This will create the necesasry .designer.cs files for your project items
Step 6: Add the existing BlogEngine.Core project to the solution
- File|Add|Existing Project
- Navigate to the DotNetSlave.BusinessLogic folder and select the BlogEngine.Core project
- Add a reference to your web application project to the BlogEngine.Core project
- I had a little trouble with this and Visual Studio got a little pissed at me but eventually it worked...
Step 7: Web.Config and Extensions...
- Go to the web.config file - specifically the system.web -> pages -> controls element
- Add an assembly attribute to the <add> element that adds the "blog" tagprefix. The attribute value should be the same as your web project name. Mine is called MyBlog so the element looks like this: <add namespace="Controls" tagPrefix="blog" assembly="MyBlog" />
- Go to the AssemblyInfo.cs file under your Properties folder of your web project
Now you may have 1 last change to make before the extensions work correclty. This will be a source code change but I'm not sure if it is necessary - It was for me and it looks like a bug but I'm not sure.
In your Utils.cs file of the BlogEngine.Core project you'll need to change the CodeAssemblies() function as follows:
public static ArrayList CodeAssemblies()
ArrayList codeAssemblies = new ArrayList();
CompilationSection s = null;
string assemblyName = "__code";
s = (CompilationSection)WebConfigurationManager.GetSection("system.web/compilation");
// No read permissions on web.config due to the trust level (must be High or Full)
if (s != null && s.CodeSubDirectories != null && s.CodeSubDirectories.Count > 0)
Type t = Type.GetType("Mono.Runtime");
if (t != null) assemblyName = "App_Code";
if (assemblyName != "__code")
Seems when you try to add an assemblyname of "__code" to the collection - things don't work out too well!