Larry Brouwer

…just my technology sandbox …for my personal amusement only!

Browsing Posts tagged Blogs

I’ve decided to implement BlogEngine.Net on the Harris County Master Gardener website. This is a website I developed as a way for the Master Gardeners to update their profiles and keep track of their volunteer hours.

I use subversion to track changes to the website. It’s free and it works great! You can read all about it here: http://subversion.tigris.org/ There are basically 3 things you need to install to get it going for your development environment:

  1. Download and install Visual SVNon your server or workstation where you’ll want to store your repositories. Install only the free server portion. That’s all you should need to get you started.
  2. Download and install TortoiseSVNeverywhere you will be using SVN. This is the client software, and works great with file explorer.
  3. If you use Visual Studio, download and install AnkhSVNon your development workstation. This will integrate all the SVN features right into VS.
  4. For documentation, here’s a great reference guide: http://svnbook.red-bean.com/

On to the installation. Here’s my installation steps:

  1. Do an SVN update of …Website solution to get current version of solution. Use SVN clean. Keep it clean!
  2. Download latest source version of the blog software from BlogEngine.Netto my desktop. Right click zip file, select properties, and click ‘Unblock’. Otherwise VS might not trust my new project location.
  3. Right click the zip file, and choose ‘Extract files…’. Extract to my project folder ‘C:\…\Visual Studio 2008\Projects\…Blog’
  4. In Visual Studio 2008 Solution Explorer, click on the  ‘BlogEngine.Net’ project, then click ‘Build’ / ‘Add Web Deployment Project…’. Rename the deployment project, ‘…Blog_deploy’. This will add a new project to the solution. It will make deploying a simpler process later.
  5. Open SSMS (Sql Server Mgmt Studio). Connect to Development instance. Add new ‘…Blog’ database.
  6. Create new user login for ‘…Blog’ database. See Installed BlogEngine.Net post.
  7. Run ‘MSSQLSetup1.6.0.0.sql’ setup script inside BlogEngine.Net/setup/SQLServer directory. Altered script at beginning as ‘use …Blog’.
  8. Renamed ‘Web.Config’ in BlogEngine.Net folder to ‘Web.Config.Orig’. Copied ‘SQLServerWeb.Config’ from setup folder as new ‘Web.Config’.
  9. Copied ‘web.config.dev…’, ‘web.config.prod…’ from ‘…Website’ project folder to ‘BlogEngine.Net’ project folder. Alter to change connection strings to work with dev, prod db’s. Also add the files to project with VS file add existing items.
  10. Changed ‘Web.config’ to use a file for specific connectionStrings. This allows me to point to different environments. I’ve learned a lot since I used this method, next time, I’ll try something different.
  11. In Visual Studio, open up the ‘default.aspx’ file and attempt to view in browser. It works! Yea!
  12. Now complete the initial configurations, i.e. set up users, etc. Remember, only working with dev database for now.
  13. Remote log into the Web Server, open Visual SVN. Add a new repository. I need to do this because when I originally created the SVN repository for the website, I didn’t fully understand a proper directory structure. Will be better next time. Also, if I change now, then I have to change it everywhere it is currently cached. So create a new repository called ‘…Blog’. Select Action / Copy URL location.
  14. Using File Explorer go to ‘C:\…\Visual Studio 2008\Projects\…Blog’ directory. Then right click on ‘…Blog’ folder and select TortioseSVN / import. This adds all the project files into SVN.
  15. Paste the URL into the import statement for SVN to import the newly created ‘…Blog’ project. Click Ok. Accept the poor certificate warning message. Enter user credentials, check Save authentication, and click Ok. The files are copied to the repository. Long wait!
  16. Rename the project folder ‘…Blog’ to ‘…Blog.Orig. Then right click on the Projects folder and select ‘SVN Checkout’. Paste in the URL location. Click Ok. Again, wait until all files are added.
  17. Open the ‘…Blog’ in Visual Studio. Choose ‘Release’ ‘Any CPU’. Then right click ‘…Blog_deploy’ project and select Build.
  18. Open File Explorer and navigate to the ‘…Blog_deploy’ folder. Right click and choose ‘SVN Commit…’. Click ‘Select / deselect all’ at the bottom. Press Ok. Now we have a ‘Release’ deployment folder available to us with SVN on the Web Server.
  19. Remote log into the Web Server. Open File Explorer. Navigate to the ‘C:\…\dev\’ folder. The folder where the development Web Application is located.
  20. Open VisualSVN Server. Navigate to the ‘…Blog_deploy\Release’ project folder. Select Action, ‘Copy  URL to Clipboard’.
  21. Using file explorer, right click on the ‘dev’ folder, and select ‘SVN Checkout’. Paste the URL into the URL of repository field. Rename the output folder to ‘…Blog’. Click Ok. The new project folder is created for dev.
  22. Open IIS7 Manager. Navigate to the ‘…Dev’ site. Right click and choose ‘Add Application’. Alias name it ‘Blog’. Browse to the physical path. Choose ‘MSSharePointAppPool’. Click Ok. Restart the ‘…Dev’ Site.

At this point, I ran into some trouble. When attempting to bring up the blog sub-application, I kept getting a yellow screen error: Configuration Error. Upon some time consuming googling, I ran across this post by Colin Cochraneand it quickly solved my problems.

To resolve this issue, in the web.config file of the parent application, I surrounded the system.web section with:

<location path="." inheritInChildApplications="false"> 
 
<system.web>
  …
 
</system.web>
</location> 

and it fixed it nicely!

What’s next? Need to customize the css to make it fit in with the Master Gardener’s website. Then move it all to prod.

Over the past several months, I’ve been wanting to start a journal to keep track of all the encounters of my daily programmer life. Until now, I’ve mainly used Microsoft Outlook’s Journal feature. This works fine, but it doesn’t publish it for all the world to see. What if I actually do discover something useful for others to get some good out of it? I could have taken the easy route and just used an existing blog site or facebook I suppose. But, since I’m in learning mode, why not set up my own website, with my own personal blog? What a cool idea, right? So I set off googling and stumbled upon BlogEngine.Net. This link gives you some more choices of what’s currently out there: http://csharp-source.net/open-source/bloggers It’s a customizable open source ASP.Net blog application written C#. Link to BlogEngine.Net .

For the sake of this blog entry, I’ve already got my environment ready to go.

Steps to installation:

  1. Downloaded the source code from: http://blogengine.codeplex.com/releases/view/39387 (at the time of this posting version 1.6 is current). I downloaded the source because I want to be able to see what’s going on inside.
  2. Extracted the source to my local Visual Studio projects directory. I’m currently using Visual Studio 2008.
  3. Opened the solution in VS2008. I immediately added a "Web Deployment Project" by first selecting the BlogEngine.Net project, then selecting "Build" "Add Web Deployment Project…" from the menu. The Web Deployment feature is not native to VS2008, you need to download and install it if you don’t already have it. Search on "Visual Studio 2008 Web Deployment Projects – RTW"
  4. Rebuild the application. Make sure you choose "Release" from the main menu and not debug (if you’re ready to deploy it). Then select the new deployment project "BlogEngine.NET_deploy", right click and choose build.
  5. Using explorer, go into the project directory, then into the BlogEngine.NET_deploy directory, then into the release directory. Visual Studio has created a nice deployment package for you. So now you can copy all the files from here into your web root directory.
  6. Add the new application into IIS7.
  7. Update the file permissions to the "App_Data" folder to allow for IIS7 to have write permissions.
  8. Finished setup!

Issues:

In step 2, I originally saved the solution as a zip file on my desktop. Then I extracted it with explorer to my project folder. After I extracted the solution, and opened it with Visual Studio, and VS gave me a warning message: "The project location is not trusted". Why would this be? I’ve had this error before, but it was on a file share path to a server. But this project is located on my hard drive. After some googling, I discovered a trick from leedumond.com. I needed to alter the permissions on the zip file first. So right click on the file, then select properties, then in the general tab, click the "Unblock" tab prior to extracting the file.

I had some troubles initially getting IIS7 to display the blog at first. I was getting an error screen. First, to figure out what the problem was, I went into the Web.Config file in the main folder, and changed the customErrors mode="RemoteOnly" to "Off". This allows me to see any errors from any browser, and not just on the server. The problem turned out to be file permissions on the App_Data folder. I used the procedure outlined in the installation instructions, and solved the problem straight away.

Additional thoughts:

If you’re wanting to publish the BlogEngine.Net application to a remote server, you can do it directly in VS 2008 with the Build / Publish Web Site option. You can use FTP or you’ll need the front page extensions loaded on the remote web server. See this great article: Using Visual Studio 2008 with IIS 7. Download the FrontPage 2002 Server Extensions for IIS 7.0here.

So, now, my new blogging application works great! But I wanted to take it that last step further. I wanted to hook it up to my SqlServer database. After reading the instructions, it all looked pretty straight forward. Here are the steps involved:

  1. Open up SSMS (Sql Server Management Studio).
  2. Create a new database. Let’s use blogDb.
  3. Create a new user and grant access to the new database. Let’s use blogUsr. I wanted to create a Sql Server user and not have my application log in as a Windows user. Here is the script:
    use blogDb; 
    go 

    create login blogUsr with password = ‘blogUsr’, check_policy = off 
    go 

    create user blogUsr for login blogDb; 
    go 

    grant alter to blogUsr; 
    go 

    sp_addrolemember ‘db_datareader’, ‘blogUsr’ 
    go 

    sp_addrolemember ‘db_datawriter’, ‘blogUsr’ 
    go

     
  4. Renamed Web.Config to Web.Config.Orig in the BlogEngine.Net project folder, and copied SQLServerWeb.Config in the setup\SqlServer\ directory to Web.Config in the BlogEngine.Net folder.
  5. Edited the connection string in the new Web.Config file to point to the SqlServer database. Here is the connection string used:
    <add name="BlogEngine" connectionString="Data Source=WebServer\MSSQLWEB;User ID=blogUsr;Password=blogUsrs;persist security info=False;initial catalog=blogDb;" providerName="System.Data.SqlClient"/>

  6. Bring up BlogEngine.Net in a browser and reconfigure it. Done!

Final note: I installed a utility called ieSpell which allows me to spell check my posts directly in the browser editor window.

Continuing my quest for knowledge and efficiency, I’ve come across Windows Live Writer. This little program runs quite well with BlogEngine.Net. I also downloaded and installed, Carlos Aguilar Mares’s Colorized Codeplug-in, which I used nicely in the above code section.