|
Hey Eric,
yep, BE 2.5 can be converted to a web project. The razor templates should work as well. I was hoping to do a more thorough post on the process at some point, but given how busy I am these days that may never happen. So I've pasted below
my own crib notes on the process I went through. These notes were initially just for me to remind myself how I did it next time I need to. But they may provide just the trick for you. I appoligize that the explainations for each point aren't
more thorough, but if you are use to working in visual studio, they may be sufficient.
Hope they help,
-Ron
Steps I used to convert BE 2.5 to a Web Application Project
1)
Initial stuff to create Web Application Project (create the project, include the files, etc)
2)
Make sure the BlogEngine.Net Web Application Project has the following properties set:
- Assembly Name: BlogEngine.Net
- Default namespace: can be anything. But I like BlogEngine.
3)
We want to compile most of the source code that’s in the App_Code directory directly into our BlogEngine.Net.Dll, but there are a few files in App_Code/Helpers that can’t be precompiled since they are razor helper .cshtml files. So
here’s what we need to do
- Create a directly called Old_App_Code
- Move all the folders from App_Code to Old_App_Code except Helpers
i.
Note: one consequence of moving the Extensions folder out of App_Code and into Old_App_Code is that it will no longer be possible to view or edit the source code of an extension from the browser. Which is a good thing from a security perspective. But, if want
to browser view or edit some extensions, create an App_Code/Extension folder and place those extensions in there. Note, it won’t work to put all the extensions in there because some of the extensions that ship with the code base are referenced from other
pages, so their code behinds need to be compiled into the main dll. (e.g the captcha extensions) But you can put other extensions in the App_Code/Extension folder if you want to be able to view and or edit their source code via the browser.
- Move App_Code/Helpers/RazorHelpers.cs to Old_App_Code/RazorHelpers.cs (‘cause this is a .cs file not a .cshtml file and we want to be able to reference it’s static class from other pages)
- Right click to view properties for Old_App_Code/Helpers/RazorHelpers.cs to verify that it’s “build action” is set to compile. I was having an issue for a while due to the RazerHelpers class not being available to the RazorHost theme’s
site.master page because this was set to content.
4)
Add References to BlogEngine.Net to the following files in the Bin directory
- System.Web.Razor.dll
- System.Web.Services.dll
- System.Web.WebPages.dll
- System.Web.WebPages.Deployment.dll
- System.Web.WebPages.Razor.dll
5)
The project won’t compile because a half dozen aspx pages didn’t generate aspx.designer.cs files due server controls in the same project not being compiled yet and used on those pages.
- To resolve this, exclude these aspx page from the project
- Get the project to compile
- Then include these aspx pages again in the project
- The recompile the project
6)
Along the way to trying to do #3, you may see an error about site.master having a duplicate page load. This is because two of the themes that ship with this version have the same code behind class name. i.e. /themes/Standard/site.master and /themes/TitaniumX/site.master
both call their code behind class “StandardSite”
- To solve this, rename the code behind class for /themes/TitaniumX/site.master to TitaniumSite (both the class name) and the inherits page attribute on the .master page.
7)
Made this web.config changes:
<pages
enableSessionState="false"
enableViewStateMac="true"
enableEventValidation="true"
controlRenderingCompatibilityVersion="3.5"
clientIDMode="AutoID">
<controls>
<!--//MOD: Web App Project FIX -RonC
-->
<!--<add namespace="App_Code.Controls" tagPrefix="blog"/>-->
<add
assembly="BlogEngine.Net"
namespace="App_Code.Controls"
tagPrefix="blog"/>
</controls>
</pages>
8)
Added an AssemblyInfo.cs to the Web Project in the Properties folder. The file must contain the following line: [assembly:
AssemblyConfiguration("")]
so that the Utils.c CodeAssemblies() method will load the BlogEngine.Net.dll as part of the system’s process for loading compiled extensions. Otherwise extensions in BlogEngine.Net.dll will not be loaded.
9)
Changed default visual studio project configs so that pdb files aren't generated for release builds. Steps: right click project in VS, select properties. Got to Build Tab, Select Release from the configuration drop down, click the Advanced…
button in lower right corner, set debug info to none, click ok, then select save from the file menu. (It’s really dumb that VS defaults to generating a pdb for a release build, but thankfully it’s fixable.)
Have some un-resolved classes? Tip: if there is any class that’s not being found, right click on the file containing that class and make sure it’s “build action” is set to compile rather than content. If a file is
placed in the App_Code directory, visual studio will auto set it’s property to content, but when the file is moved back to a different directory, VS doesn’t auto set the attribute back to compile even if it’s a .cs file.
|