This project is read-only.

Any have BE 2.5 running as Web Application Project?

Aug 24, 2011 at 2:10 PM

I am curious if anyone has successfully gotten 2.5 converted to a web application? 


I've followed tutorials for version 1.x /2.0.  With some small adjustments, the tutorials allowed me to get the site running as a web app.   The one glaring exception, however, are the Razor pages.  In particular, the pages rely on the new Razor helper methods. 

  • I've seen a few posts identifying the issue (like ).   It comes down to the CSHTML pages referencing Helpers.AdminHelpers.<you function here>.
  • Scott gu's explaination ( seems to indicate the items are only available across the site when located in App_Code, which necessarily goes away in a WAP.
  • I made it a good deal further using David Eboo's "Razor Generator" ( (,   The problem, however, is that Razor Generator creates static classes and the Razor Helpers in blog engine rely on instance methods like  Request and Response.
  • I guess rewriting and compiling the helper methods would work, but that kind of defeats the purpose of using a pre-built package like BE.

So I  guess it comes down to :  is converting 2.5 to a web app project a pipe dream? Should I give up?  Anyone done it successfully?


Aug 24, 2011 at 6:45 PM

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,


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:

  1. Assembly Name: BlogEngine.Net
  2. 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">


         <!--//MOD: Web App Project FIX -RonC -->

         <!--<add namespace="App_Code.Controls" tagPrefix="blog"/>-->

         <add assembly="BlogEngine.Net" namespace="App_Code.Controls" tagPrefix="blog"/>




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.

Aug 24, 2011 at 7:58 PM

Duh !   The key piece (for me at least) is "move all the folders from App_Code to Old_App_Code except Helpers"     Meaning  --> leave the helpers as app code.    No idea why this didn't cross my mind.  Thanks !


Aug 24, 2011 at 9:57 PM

Cool - glad you could decypher my crib notes and got it working.  Excellent!


Sep 11, 2011 at 8:51 PM
Edited Sep 11, 2011 at 8:52 PM


I took the time to write up the steps.  Thought I would pass along the link.

Sep 12, 2011 at 1:02 PM

Eric - Thanks for writting this up to help other people out and leting me know about the blog post.  Awesome.


Mar 22, 2012 at 3:59 PM
Edited Mar 22, 2012 at 4:00 PM


Thanks for your notes.  I'd prefer if you distributed a WAP to begin with because it makes configuration and debugging so much easier than with a website project.  The process to convert it manually isn't too bad, though it's going to make upgrading more difficult for me in the future.

Note that you can create all of the .designer.cs files very easily by right-mouse clicking the web application project in Solution Explorer and selecting Convert to Web Application.  More info:

Also, I prefer to generate a .pdb file for release builds because it provides file names and line numbers in exception stack traces.  This makes debugging much easier; however, keep in mind that due to JIT optimizations the line numbers sometimes don't line up exactly, so you must use caution when interpreting exceptions.

- Dave

Mar 26, 2012 at 1:40 PM


Glad you found the notes helpful for converting to a Web Application Project.  Like you, I'd prefer the the main codebase were kept as a WAP rather than a website project.  I too find that debugging via a Web Application Project is much more productive and time efficient. 

Perhapse if we can get enough people wanting this change it could happen.  One place I've see people post feature requests is here  Please add your comments.  Also, I kinda remember seeing some place on codeplex where we can vote on specific features and the WAP requst was on the list as I recall.  But at the moment I'm having a hard time finding that area of codeplex so I was unable to provide you with a link.  If you find it, can you post the link to this thread so that other can easily find it and vote up the WAP request?


Mar 26, 2012 at 2:06 PM

Hi Ron,

I found a work item here:


- Dave

Mar 26, 2012 at 3:04 PM

Take a look here.

Mar 26, 2012 at 4:29 PM


Thanks, I didn't know there was a WAP version already.  Shouldn't there be a link on the download page?

"each new release will have matching WAP version and we’ll have a link from downloads page pointing to that version for people who prefer it"

There's no link here:


Mar 26, 2012 at 5:13 PM

There wasn't, this project published just yesterday. We expecting new BE release next month, then you'll see link to WAP version. But you can use converted source code now.

Mar 27, 2012 at 1:00 PM


This is a great step forward.  Will I be able to update my local tortoiseHq repository based on a Web Application Project?


Mar 27, 2012 at 3:12 PM

This is a separate project, not a fork. You can clone it to your local HG repository and keep updated, but if you made any changes to your local BE you'll have to merge them manually.

Mar 28, 2012 at 1:41 PM

Rtur,  I'm thinking I might need to do a happy dance.  Does this mean that I can make contributions through this Web Application Projectas easily as through the website project (pull request etc)?

Mar 28, 2012 at 3:10 PM

I'd prefer it going the other way - contributions to BlogEngine.NET will always make it to WAP version. Unless this is something very specific to web application and not applicable to website, but that would be rear exception. We want to keep two in sync as much as possible.