HOWTO: Convert BlogEngine.NET from Web Site to Web Application Project

Posted by

Much thanks to BenAmada for providing on this thread a step-by-step guide for converting the downloadable BlogEngine.Net Web Site Project to a Web Application Project.

This varies a bit from the MSDN Documentation walkthrough on moving an ASP.Net Web Site Project to a Web Application Project as there are some added steps due to several reasons in the architecture of BlogEngine.Net e.g. the way BlogEngine does themes, its widgets framework and controls dependencies. These are not to criticise the design decisions made, it still is a full featured, well built blogging application which I use and customise daily.

Here are the steps repeated, but I encourage anyone benefitting from this to post your thanks to Ben on this thread as well so that he knows.

1. Create a new WAP.  File -> New -> Project -> Visual C# -> ASP.NET Web Application.  Select the location (I created a new folder for this WAP project), and I used ‘BeWap’ for the Name of the project.

2. Close Solution.

3. In Windows Explorer, copy all the BE files into the WAP folder.  You’ll be overwriting a couple of the files that were included in the new WAP project we created (default.aspx and web.config and maybe a couple of others).

4. Rename the App_Code folder to Old_App_Code.

5. Reopen WAP solution in Visual Studio.

6. Right-click on project name (BeWap) in Solution Explorer, and select ‘Add Reference’.  Go to the Browse tab, and browse to the BIN directory in this project, select ‘BlogEngine.Core.dll’.

7. In Solution Explorer, click the ‘Show All Files’ icon.  All the files/folders that we copied into the WAP folder will show up in Solution Explorer, but they are not yet included in the project, so they are white/ghosted out icons.  Select all these ‘excluded’ folders/files in Solution Explorer, right-click and select ‘Include in Project’.

8. Select the top node in Solution Explorer, ‘BeWap’ (right under Solution ‘BeWap’).  Right-click and select ‘Convert to Web Application’.

9. Save all files (Ctrl-Shift-S).

10. In the web.config file, in the <pages> section, there’s this line:

<add namespace=”Controls” tagPrefix=”blog”/>

Change that to:

<add assembly=”BeWap” namespace=”Controls” tagPrefix=”blog”/>

… where “BeWap” is the name of this WAP project.

11. The site.master files for Indigo, Mobile and Standard all have the same class name of ‘site’.  Change the class name in site.master.cs for the Standard theme to site_standard and changed the Inherits attribute in the <%@ Master %> directive in site.master to site_standard (so they match).  Need to do the same thing for the Indigo and Mobile themes … giving them class names of site_indigo and site_mobile.

12. The class name in edit.ascx, edit.ascx.cs and edit.ascx.designer.cs files in the RecentComments widget is widgets_RecentPosts_edit.  Need to change the class name in these 3 files to widgets_RecentComments_edit.

13. The class name in edit.ascx, edit.ascx.cs and edit.ascx.designer.cs files in the TextBox widget is widgets_LinkList_edit.  Need to change the class name in these 3 files to widgets_TextBox_edit.

14. The class name in widget.ascx, widget.ascx.cs and widget.ascx.designer.cs files in the TextBox widget is widgets_LinkList_widget.  Need to change the class name in these 3 files to widgets_TextBox_widget.

15. Save all files (Ctrl-Shift-S).

16. When trying to build the project, I was getting about 47 errors about unrecognized controls.  The problem was the ‘designer.cs’ files didn’t get created for these ASPX pages back in step 8 when I did the ‘Convert to Web Application’ command.  Even if I try repeating that step again, the designer.cs files still do not get created.  Visual Studio is complaining that various BE controls (blog:SearchBox, blog:PageList, etc) are unknown server tags.  If Visual Studio can build the project once, then these BE controls will start to get recognized.  What I did to get this done was temporarily exclude these pages that reference the BE controls.  The pages referencing these controls can be found in Visual Studio’s error list when you try to build the project.  I excluded the entire Widgets folder, the entire themes folder, the post.aspx file, the error404.aspx file, the default.aspx file and the apiTagMiniView.aspx file.

17. Build the solution.  Should get no errors.

18. Add those temporarily excluded items back into the project from two steps ago.

19. Select the top node in Solution Explorer, ‘BeWap’ (right under Solution ‘BeWap’).  Right-click and select ‘Convert to Web Application’.  The pages we re-included back into the project should now all have designer.cs files.

20. Build the solution.  Should get no errors.

21. Run the solution.  Everything should work.

38 comments

  1. Hi its a good post . But I am having a problem in extensions. Then I tried to change the Old_App_Code to App_Code but its giving me the error The type ‘ExtensionManager’ exists in both ‘c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\nuqta-e-nazar\a98cceb7\b62ec585\assembly\dl3\9b83e8fa\2cc29650_dcc8c901\WAPP_Nuqta-e-Nazar.DLL’ and ‘c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\nuqta-e-nazar\a98cceb7\b62ec585\App_Code.1yitbbas.dll’
    Can somebody help me

  2. In order to make the extensions work again you must change one line in the BlogEngine.Core project Utils.cs file.
    Locate this line:
    //string assemblyName = “__code”;
    and change it to:
    //string assemblyName = “ASSEMBLYNAME”;
    Following the original post example it could be BEWAP.

    Then, in order for the application to show the contents of the extensions you need to make a change in the Editor.aspx.cs file
    Change the line:
    fileName += assemblyName + “\\Extensions\\” + _extensionName + fileExt;

    into:
    fileName += “\\old_App_Code\\Extensions\\” + _extensionName + fileExt;

    where old_app_code is the folder where the classes are located now. According to the example. They can actually be anywhere.

    Hope it helps

  3. Forgot this:
    1. Remove the \\ in front of the old_app_code
    2. Remove the // comments in the first 2 lines.
    That’s it. Sorry about that. I’m sleepy 😉

    1. Johnny, thank you so much for your comment. I had figured everything out on my own, but could not figure out why my comment emails were not being sent.

      You saved me hours of digging.

  4. Hello,
    Your post has been really helpful in the past as it did the job nicely for BlogEngine v1.6 but now that v2.0 is out can you give us a new post that gets around their updates please?

    It seems like they’ve used partial classes with methods in different physical places but are now put under the same namespace with the same class names. Hope you can help us out.

    Many thanks!

  5. I think this is one of the most important info for me. And i’m glad reading your article. But wanna remark on some general things, The website style is perfect, the articles is really nice : D. Good job, cheers

  6. I’ve read this post and if I could I wish to suggest you some interesting things or tips. Perhaps you can write next articles referring to this article. I want to read more things about it!

  7. I have to express some appreciation to you just for rescuing me from this circumstance.

    Because of surfing throughout the internet and seeing views which
    are not productive, I figured my life was gone.

    Living without the presence of solutions to the problems you have sorted out by way of your
    main guideline is a crucial case, as well as those that would have badly damaged my career if I had not come across the website.
    Your main competence and kindness in controlling a lot of stuff was very useful.
    I don’t know what I would’ve done if I hadn’t discovered such a step like this. I can also now look ahead to my future. Thanks for your time very much for the reliable and result oriented help. I won’t
    hesitate to refer the blog to any person who should have assistance on
    this subject matter.

  8. W momencie wykańczania wnętrz potrzebna jest spora gama akcesoriów, o których część osób nie myśli wybierając materiały podstawowe takie jak drzwi zewnętrzne albo podłogi

  9. I drop a comment whenever I especially enjoy a post
    on a site or if I have something to valuable to contribute to the
    conversation. It is triggered by the fire displayed in the post I read.
    And after this post HOWTO: Convert BlogEngine.NET from Web Site to Web Application Project | Redditech ‘Ground Zero’ Blog.
    I was moved enough to create a thought 😉 I do have some questions for you if it’s allright. Is it only me or do some of these remarks come across like they are written by brain dead people? 😛 And, if you are writing on additional places, I’d like to follow you.
    Would you make a list all of all your public pages like
    your linkedin profile, Facebook page or twitter feed?

  10. Aw, this was an incredibly nice post. Taking a few minutes and
    actual effort to generate a superb article… but what can
    I say… I procrastinate a lot and never seem to get
    anything done.

  11. You actually make it seem so easy with your presentation but I
    find this topic to be really something which I think I would never understand.
    It seems too complicated and very broad for me. I am looking forward
    for your next post, I will try to get the hang of it!

  12. Greetings! Very useful advice in this particular post! It is
    the little changes that make the most important changes.
    Thanks a lot for sharing!

  13. I was suggested this blog by my cousin. I am not
    sure whether this post is written by him as nobody else
    know such detailed about my difficulty. You are wonderful!

    Thanks!

  14. Howdy! I know this is kinda off topic but I
    was wondering if you knew where I could find a captcha plugin for my
    comment form? I’m using the same blog platform as yours and I’m having trouble finding one?
    Thanks a lot!

  15. Today, I went to the beachfront with my kids. I found a
    sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is totally off topic but I
    had to tell someone!

  16. Magnificent items from you, man. I’ve remember your stuff prior to and
    you are just extremely wonderful. I really like what you’ve got right here, certainly like what you’re stating and the way in which during
    which you are saying it. You are making it enjoyable
    and you continue to care for to keep it wise. I can’t wait to
    learn far more from you. This is actually a tremendous web site.

  17. Howdy I am so happy I found your blog page, I really found you by error,
    while I was looking on Digg for something else, Regardless I am here now and would just like to say kudos for
    a fantastic post and a all round exciting blog (I also
    love the theme/design), I don’t have time to read it all at the minute but I have book-marked it
    and also added your RSS feeds, so when I have time I will be back to
    read a great deal more, Please do keep up the fantastic
    work.

  18. I would like to thank you for the efforts you have put in penning this site.
    I really hope to see the same high-grade blog
    posts from you in the future as well. In truth, your creative writing abilities has encouraged me to get my own blog now
    😉

  19. Thank you a bunch for sharing this with all people you really realize what you are speaking approximately! Bookmarked. Kindly also seek advice from my website =). We could have a hyperlink alternate agreement among us|

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.