Archive for February, 2008

February 29th, 2008

Congratulations Penn State THON and Alpha Phi Delta

I would like to congratulate the Penn State IFC/Panhellenic Dance Marathon (THON™), it is the largest student-run philanthropy in the world, and this past weekend they raised $6,615,318.04 for children with cancer. And a special congratulations to my fraternity Alpha Phi Delta, Chi Chapter, for participating and helping to raise money for this great cause.

Tags: , , , , , , , , ,

Posted in News, Personal | kick it on DotNetKicks.com | Bookmark | View blog reactions | No Comments »

February 27th, 2008

ASP.NET MVC Route Validation and SEO

Recently I have been using the ASP.NET MVC framework for a project at work. And one of the requirements was that certain data inputed in to the URL be tightly verified. I originally thought that data was verified by the type specified in the ControllerAction, however I came to find out that it wasn’t. So if you have say a page number and the user enters a letter in the URL the application just proceeds on it’s marry way. For example on the Kigg site:

  1. http://kigg.dotnetslackers.com/Story.mvc/Category/Lifestyle/1
  2. http://kigg.dotnetslackers.com/Story.mvc/Category/Lifestyle/a
  3. http://kigg.dotnetslackers.com/Story.mvc/Category/Lifestyle/
  4. http://kigg.dotnetslackers.com/Default.aspx

I am not sure yet if this is because Kigg is implemented with a int? and any failure of the parsing results in a null. But that wouldn’t explain the 3rd result in which Kigg returns the category as if it was the 4th result. I would expect that the 3rd result should return the same results as the 1st result. This setup can results in many SEO issues where I can inject keywords in to the URL with malicious intent and still have it resolve correctly. For example:

  1. http://kigg.dotnetslackers.com/Story.mvc/Category/Lifestyle/coderjournal

So my recommendation to my readers is to also implement a URL Rewriter to force normalization on to the MVC URLs. I am personally using my own URL Rewriter on this project that I am creating to better control my inputs, by providing type validation, into my application. At the very least use the built in verification and don’t put null in the defaults.

RouteTable.Routes.Add(new Route {
	Url = "[controller]/[action]/[page]",
	Defaults = new { controller = "Home", action = "Index", page = 1 },
	RouteHandler = typeof(MvcRouteHandler),
	Validation = new { method = "GET", page = "[0-9]+" }
});

The Validation property that you see on the last line above allows the type of HTTP Method allowed POST or GET usually. And the other properties are similar to what you do with the Default only they are RegEx statements that validate the specific part of the URL.

Really what I would like to see from ScottGu and the rest from the MVC framework is a more extensible Route object or RouteTable. I was really surprised that I wasn’t able to overload the handling of the URL in the MVC framework. Don’t get me wrong the team has done a great job hitting 95% of the potential needs of the development community. However if you fall in that 5% you are either out of luck, or forced to create a new Module, Controller, RouteTable, Route, and a whole host of supporting objects. For instance if I wanted to give the users of my URL Rewriter and Reverse Proxy a common interface that they can both do their advanced URL Rewriting and Reverse Proxying and their MVC Action/Controller setup. I wouldn’t be able to do it unless I basically reimplemented the URL handling of the MVC framework. I might end up doing that in the future, but I will probably wait until the Gold Version of MVC is released. If this was a perfect world I would probably implement some syntax in my URL Rewriter Rules file that looked like:

# if not feed burner requesting
RewriteCond %{HTTP_USER_AGENT} !^FeedBurner.*$
# rearrange old structure
RewriteRule ^/<?'controller'([a-z]+)>/index.html$  /$1/List/page$2.html [C]
# in to new MVC model
RewriteRule ^/<?'controller'([a-z]+)>/<?'action'([a-z]+)>/page<?'page'([0-9]+)>.html$  {controller="Home",action="List",page=1} [MVC,NC,L]

But that is just me making a wish for the future of MVC extensibility. All that I would need to accomplish this task is a little more flexibility in the URL handling. If anybody from the MVC wants to talk to me more about my requirements please feel free to contact me.

Really the last thing, I imagine, that the MVC team would want to cause is more SEO problems than are already created by uneducated developers.

Tags: , , , ,

Posted in ASP.NET, C#, Personal | kick it on DotNetKicks.com | Bookmark | View blog reactions | 1 Comment »

February 25th, 2008

What I Learned About MVC On Day One

I am really blown back about how fast and easy MVC is to develop with.  I know the guys at Microsoft do a good job with their .NET coding, but I am really impressed by the forethought they put in to MVC.  It builds on top of the standard ASP.NET package, but does it in such a way that makes it lean on top of the already feature-rich (read bloated) ASP.NET Page object.  It really doesn’t feel like I have all that baggage anymore.

These are the following links that got me started designing my very first MVC application.

Keep a watch on my blog about for my posts about Unit Testing MVC and using Validators in the Routing table.  Also I am currently exploring if it is possible for my URL Rewriter and Reverse Proxy to be used in combination with the MVC Routing table.  I will keep you informed.

Tags: , , , , ,

Posted in ASP.NET, C# | kick it on DotNetKicks.com | Bookmark | View blog reactions | 8 Comments »

February 25th, 2008

Google Lets You “Chatback” With Your Visitors

As many of you may know I love Google Talk. I love it because of its light foot print both on my hard drive and when running in memory. I love the integration with all my Google services. And I love the flexibility that it provides. If you would like a copy of it, you can download it as part of the Google Pack. Or by it self from http://www.google.com/talk.


However the Google Talk team just gave me another reason to love Google Talk. It now allows me to have direct conversations with my visitors with a simple click of the mouse on the chat bubble you see to your left.

This new feature is called chatback and allows you to integrate Google Talk in to any website you have access to add HTML. Chatback uses the web-based Google Talk Gadget so your visitors don’t need to download anything. It opens in a new window so they can keep chatting with you even if they browse to other pages.

Of course, chatback isn’t just for blogs. You can use it on any web page that you can add HTML content to. To get started, visit the chatback start page. (This is also linked from the Google Talk homepage.) Then just copy the provided HTML snippet to your web site. Visitors will then see a badge on your site indicating your availability, and can click to start a chat with you. If there’s a time when you don’t want to be distracted, just set your online status to “busy” and visitors won’t be able to chat with you until you change your status back to “available.”

So now if you want to chat with me about anything and you see a Green dot. You have the go ahead to say hi or ask me any question you want. I may not always respond, because I sometimes forget to turn of GTalk when I am in a meeting or giving a presentation.

Tags: , , , , ,

Posted in News | kick it on DotNetKicks.com | Bookmark | View blog reactions | 5 Comments »

February 24th, 2008

Nick Berardi’s Essential Software for 2008

Every developer has their favorite tool collection that they must have in order to survive while developing software. The list below is indispensable in my day-to-day activities and that is why I am sharing it with my readers. My list was inspired by Scott Hanselman’s own list of tools that he uses. However I would be really interested to see what Scott’s actual list is since it would be almost impossible to touch each and every tool once a week as he claims. Because many of them serve the same purpose.

The goal of my list is to keep the tool list up to date with my current tool set. So if I stop using a tool it will drop to the bottom of the list in a section called Not Using Anymore.

Creative Commons License This list is licensed under a slightly different license than the rest of my site. So please do not reproduce this work in it’s entirety. I would rather you link to http://www.coderjournal.com/essential-software/, because work like this takes much of my time. And I am going to do everything that I can to make sure the links stay relevant and up to date. You have this pledge from me, because the links below are also my source for downloading these tools.

Development Tools

  • Notepad++
    This is a great program because it will open up any text based file and allow for quick editing. Also has built in context menu integration.
  • WinMerge
    This is still my favorite merge application, I know others have a growing following. But this is my chosen merge application because many of the others tools, check for and integrate this tool with their own to provide a free collaboration toolset.
  • PuTTY
    PuTTY is a wonderfully portable tool that doesn’t require an installation and can easily allow you to make SSH connections to any source that you may need to. I personally use it to create a tunnel in to my home network, which provides me complete access to all my computers via remote desktop with out exposing them on the internet.
  • PowerShell
    PowerShell allows for some advanced script processing and is readily being integrated in to many Microsoft projects. Now is a great time for developers to jump on board.
  • Reflector
    Reflector allows you to peer in to the .NET assemblies and view the code in your preferred language.
  • CodeSmith
    Great tool for generating any type of code that you may need from a template.
  • Fiddler
    This tool is one of my favorites because it allows me to watch the HTTP requests and view the headers. Fiddler acts as a proxy between for your HTTP connections.
  • NRegEx
    This JavaScript based tool RegEx evaluator is a great way to quickly test your regular expressions.
  • RhinoMock
    I have just started using RhinoMock for my unit testing and it really is an amazing piece of code.
  • WireShark
    WireShark use to be called Ethereal and monitors all network connections that pass through your network card.
  • Microsoft Network Monitor
    Microsofts answer to WireShark.
  • URL Rewriter and Reverse Proxy
    This is my own URL Rewriter and Reverse Proxy that I have developed. It uses the Apache style mod_rewrite syntax, so it should be familiar to most developers who have worked with Apache in the past. It is not very hard to understand so anybody can easily pickup the syntax.
  • Microsoft Best Practices Analyzer
    This is a great tool that analyzes your setup on your server and makes recommendations around best practices.
  • Visual Studio Team System 2008 Team Foundation Server Power Tools
    Extra power tools that provide access additional tools that were not shipped with the Gold Version of TFS 2008. It also includes an Team Foundation Server Analyzer that makes sure you server is setup properly.
  • Visual Studio 2005 Team Foundation Server Power Tools
    Same as above only for TFS 2005.
  • Team Foundation Server Administration Tool
    This is a great tool that lets you set permissions for each project in your server. Sometimes the permissions aren’t set correctly for each project for all the servers required, including SharePoint, SQL Reporting, and TFS. This can occur in installations were users are not defined by groups.
  • Visual Studio Express
    Don’t think this one needs explaining.
  • SQL 2005 Express
    Don’t think this one needs explaining either.
  • GhostDoc
    This is a wonderful tool that lets you document your source code pretty quickly. One thing I really love this tool for is that it helps me make self documenting code, because inorder for GhostDoc to work the methods and properties have to have some English flow to them.
  • TortoiseSVN
    Great tool with Windows Explorer Integration that allows you to work with the SVN source control server directly though Explorer.
  • AnkhSVN
    Lets you work with the SVN source control server by integration with Visual Studio.
  • Consolas Font Pack
    This is a wonderful font that is very easy to read. It is highly recommended for Visual Studio. I use it as my default.
  • SmartFTP
    A great FTP program.
  • Paint.NET
    This is one of my favorite projects currently on the internet. The developer of this application is constantly pushing C# to the limits. And does a great job with usability. It also has 99.9% of everything I require from a graphic editor as a software developer. The 0.1% that is missing is Icon support.
  • Microsoft Virtual PC
    This is a must have for any developer, especially when you are required to run operating systems that are not your current install.

Firefox Add-On

  • LinkedIn Companion for Firefox
    LinkedIn integration for keeping track of contacts.
  • StumbleUpon
    Great add-on that allows you to find sites you never knew you wanted to find.
  • IE Tab
    This is probably one of my favorites because it quickly lets me switch back and forth between Firefox and IE without ever leaving the Firefox browser.
  • User Agent Switcher
    Allows you to change the User Agent of FireFox with a quick drop down menu. I usually setup a User-Agent for Google Bot to see how websites react and change to the search engine.
  • Google Browser Sync
    Keeps your bookmarks in FireFox synced between your work and home PC.
  • Firebug
    Firebug is a must have for any professional web developer. It allows deep access to the HTML in a nice tree structure and event displays code that is generated by DHTML and JavaScript.

    • YSlow
      Grades your website and provides some useful hints on improving your score.

Other Software That Makes My Life Easy

  • Mozy *** My Review ***
    Everybody should back up their computer, and Mozy provides unlimited backup for $4.95 per month. Also Mozy Pro allows you to backup your SQL Server and Exchange installs.
  • Skype
    Great for making VOIP calls to your friends and family. Also many contractors are starting to use this as their primary communication especially over seas.
  • Picassa
    Very good program for keeping track of your family photos.
  • Gtalk
    I love it because it has a very small foot print.
  • Google Pack
    Get a whole host of software provided by Google and it also updates other common programs for you, such as Skype, FireFox, Acrobat, and others.
  • 7-Zip
    I mainly use this on my Servers because it provides better and quicker support for archiving of Zip files than the built in Windows Zip Archiver.
  • PowerArchiver
    I became disenchanted with WinZip about 4 years ago, and I happened to stumble across this application that had the look and feel of WinZip but provided support for 7-Zip, RAR, CAB, ZIP, GZip, and many others.
  • Virtual TI-89
    Because every once and a while you need to graph out more complex equations.
  • CCleaner
    It’s a very good idea to clean your registry every Spring. It is really amazing the speed in boot time when Windows doesn’t have to load a bloated Registry.
  • Ultimate Boot CD
    Wonderful set of tools.
  • WordPress
    I use it on Coder Journal, and even though my forte is .NET I still haven’t found a better blogging application.
  • Windows Live Writer
    Allows for quick and easy posts.
  • Deamon Tools
    Quickly mount and dismount ISO images for your favorite software.
  • LinkedIn Outlook Toolbar
    Allows you to keep your Outlook Contacts in sync with your LinkedIn network information and connections
  • gSyncIt
    Allows me to keep my Google Calendar in sync with Microsoft Outlook, so that my wife always knows what is going on during the day. Also has the added benifit of syncing stuff from Google to Outlook when she wants to add something to my calendar.

Tags: , , , , , , ,

Posted in ASP.NET, C#, Personal, Programming, Review, SQL | kick it on DotNetKicks.com | Bookmark | View blog reactions | 1 Comment »

February 13th, 2008

Best Practices for Production ASP.NET Applications

I would like to thank Kyle Beyer of Daptivate for putting this post together. This is a great resource for developers as well as server administrators. Some of what I think are the most critical steps for any production server I have pulled out below for your browsing pleasure.

1. Generate new encryption keys

When moving an application to production for the first time it is a good idea to generate new encryption keys. This includes the machine validation key and decryption key as well as any other custom keys your application may be using. There is an article on CodeProject that talks about generating machineKeys specifically that should be helpful with this.

My Take:This is very important, which is why I think it is number 1, especially if you have a standard image that you burn on all your new servers. This is important because this is the base encryption key that .NET uses when securing any of its data/communications.

4. Set retail=”true” in your machine.config

<configuration>
    <system.web>
        <deployment retail="true"/>
    </system.web>
</configuration>

This will kill three birds with one stone. It will force the ‘debug’ flag in the web.config to be false, it will disable page output tracing, and it will force the custom error page to be shown to remote users rather than the actual exception or error message. For more information you can read Scott Guthrie’s post or the MSDN reference.

6. Set the memory limit for your application pool

When creating the application pool, specifically set the memory limit rather than the time limit which is set by default. Asp.net has a good whitepaper which explains the value of this:

By default IIS 6.0 does not set a limit on the amount of memory that IIS is allowed to use. ASP.NET’s Cache feature relies on a limitation of memory so the Cache can proactively remove unused items from memory. It is recommended that you configure the memory recycling feature of IIS 6.0.

7. Create and appropriately use an app_Offline.htm file

There are many benefits to using this file. It provides an easy way to take your application offline in a somewhat user friendly way (you can at least have a pretty explanation) while fixing critical issues or pushing a major update. It also forces an application restart in case you forget to do this for a deployment. Once again, ScottGu is the best source for more information on this. This actually returns an HTTP Response Code of “503 Service Unavailable” which is the Google friendly way of saying we are down for an update.

And my own addition to this great list would be. These are some of my own personal best practices that I try to keep.

* Don’t use the Default Website instance

I don’t like using the Default Website instance in IIS, it is created by default and much like the Automatic “First Post” which is part of any blog software, it is usually the first to be deleted on my servers. I prefer naming my web site instances after my domain that is going to be hosted, so for example in IIS for Coder Journal the web site instance is called coderjournal.com.

** Don’t use the wwwroot folder to host your websites

Much like how I don’t like using the standard Default Website instance in IIS I also don’t like using the c:\inetpub\wwwroot\ folder. I usually try to put all my websites on a separate partition. If I don’t have a separate partition I create a folder on the c:\ driver where all my websites will be stored.

Tags: , , ,

Posted in ASP.NET, How To | kick it on DotNetKicks.com | Bookmark | View blog reactions | 4 Comments »

February 12th, 2008

Lotus Notes, AOL for the Corporate World

So today I was reading Jeff’s Post on The Dramatic Password Reveal, and I had a flash back, to about a year or more ago, when I was working for a large bank based out of Pittsburgh who shale remain nameless. The flash back was to the usability nightmare that Lotus Notes and Lotus Sametime provided to anybody that had to do a simple task such as sending an e-mail (or Memo in Lotus Notes terminology). I think Jeff summed it up nicely and probably let Lotus Notes off a little easy by calling it a a massive train wreck.

Lotus Notes was so bad that I was actually considering quiting my job just to get away from the piece of software. Every time I had to look at the client interface I thought to myself where did I go wrong. This wasn’t a bad job either, it paid very well, had good benefits, however the job wasn’t really challenging. Combine that all on a 4 year old computer and a 15-inch CRT and you have my life at this job. So the lack of fulfillment and Lotus Notes drove me to look for another job after only a month and a half at the company.

I refer to Lotus Suite of Products as the AOL for the Corporate World for a couple of reasons. You have to think about AOL in terms of mid-to-late 90’s mainframe terminal interface, not AOL’s website in the new century. Unfortunately IBM hasn’t brought Lotus Notes in to this century or even the late 90’s. The following is my reasons for comparing AOL and Lotus Notes:

  1. Every link you get in your E-Mail (or Memo) needs to be opened with in the Lotus Notes client. Just like AOL required when clicking on a link in their Mail system.
  2. Every corporate form to collect information is done in a proprietary Lotus Notes data collector that tries to imitate Microsoft Access imitating a web form. Much like AOL did with all the forms available for their bazillion different pop ups.
  3. Lotus notes constantly crashed my computer. AOL did the same.
  4. Lotus notes had a built in proprietary IM client called Sametime. So did AOL. (See Lotus Sametime)
  5. If you think of everything you company has implimented, time tracking, specialized databases, calendars, task lists, corporate web, internet browsing, etc. You can bet Lotus notes has half assed that feature in to their product some how. Much like AOL did before they realized people hated that.
  6. Lotus Notes LoginThe login screen. No real gripe with AOL about this, at least AOL didn’t have hieroglyphics.

    This dialog box contains several security “features”:

    • The hieroglyphics on the left of the dialog box are supposed to distract anyone who is peering over your shoulder trying to learn your password as you type.
    • The number of characters you type is hidden; a random number of X’s appear instead of one asterisk per character.

    Is any of this nonsense really necessary? If I want to learn someone’s password as he or she types it, I will look at the keyboard, not the screen!

  7. Lotus Notes EmailThe inefficient use of screen real estate. We all take writing an e-mail for granted with our nice large boxes for TO, CC, Subject, and Attachments. However in the Lotus Notes world your name and some numbers that only mean something to Lotus Notes takes up half of the real estate. I can only image this is in case you forget who you are.

Is it any wonder why it’s often referred to as a train wreck of colossal proportions.

Apple fanboys are always talking about their wonderful interfaces that behave like a user is suppose to interact with a computer.   As sort of a sick, but probably boring, reality show I have always wanted to sit them in front of Lotus Notes and tell them to have at it.  Sort of a last man standing competition.

Also after a month on Lotus Notes, Microsoft Outlook and Exchange started to look like a gift from Heaven.

So that is my rant on Lotus Notes, it is now 12:30 AM, but I just had to get that all out.  And that was just from seeing one picture on Jeff Atwood’s website.  Imagin having to work with the application every day.

Interviewing Tip: Always ask your future employer if they used Lotus Notes, if they say yes, politely end the interview and don’t look back.  Or just bolt from the room at full speed with out looking back.  Either will allow you to achieve you goal of staying away from Lotus Notes.

Tags: , , , , , , , ,

Posted in Rant | kick it on DotNetKicks.com | Bookmark | View blog reactions | 8 Comments »

February 11th, 2008

LINQ Cheat Sheet

This cheat sheet was compiled by Milan Negovan at http://www.aspnetresources.com/. It is very handy and I recommend everybody download it and print it out.

Download: LINQ Cheat Sheet Document

Tags: , , ,

Posted in C#, How To | kick it on DotNetKicks.com | Bookmark | View blog reactions | No Comments »

February 11th, 2008

How To: Change Instance Name Of SQL Server

Recently I change the network name of one of my servers at work, because the box changed its job from a virtual machine server to the database server. Everything was going great until I decided to setup the server for replication and received the following error message.

New Publication Wizard
——————————

SQL Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address, or any other alternate name are not supported. Specify the actual server name, ‘old_name’. (Replication.Utilities)

——————————
OK
——————————

So with a little hunting and SQL queries I found out that SQL Server doesn’t use the network name, it only excepts that as an alias. My SQL Server instance was still named “old_name”. I found that out by running these two queries:

sp_helpserver
select @@servername

So in order to get the network name and the SQL Server instance name back in sync I had do these steps:

  1. Run this in Microsoft SQL Server Management Studio:
    sp_dropserver 'old_name'
    go
    sp_addserver 'new_name','local'
    go
  2. Restart SQL Server service. I prefer the command prompt for this, but you can just as easily do it in Services under the Control Panel
    net stop mssqlserver
    net start mssqlserver

Then after that is done run this again, to make sure everything is changed:

sp_helpserver
select @@servername

I don’t understand why SQL Server uses it’s own name versus the network name, might be due to the fact you can have multiple SQL Server instances install on one machine. It wasn’t too hard to change and probably stems from the days when SQL Server was known as Sybase, all in all, I learned something new and it only took 30 minutes of my day to fine the answer.

Tags: , , , , ,

Posted in How To, SQL | kick it on DotNetKicks.com | Bookmark | View blog reactions | 8 Comments »

February 10th, 2008

How to use the .NET URL Rewriter and Reverse Proxy to run WordPress on IIS

First off I would like to say that many of my readers are very intelligent, they picked up on a one line sentence in my last post about my new design and Coder Journal switching from Linux to Windows.

I also moved hosts from GoDaddy’s shared Linux hosting. To GoDaddy’s virtual dedicated hosting on Windows. This proved difficult since URL Rewriting isn’t currently built in to IIS 6.0 like it is in Apache. I will talk a little about this setup in a later post.

Switching from Linux to Windows wasn’t the part that really intrigued many of them, it happens every day so why would it? It was the fact that I was able to get the same level of URL Rewriting out of IIS 6.0 as I was out of Apache’s mod_rewrite and still be able to make WordPress look and function like it was running on Apache.

So to get started I just want to say, while I know there are other solutions out there to get WordPress hosted on IIS with the exact same outcome as what I am going to present below. I did this for the following reasons:

  1. I am a .NET guy and I love developing software that is popular on other platforms on .NET just to see if it can be done.
  2. I also believe in Eating One’s Own Dog Food, and the URL Rewriter and Reverse Proxy that I am presenting below, and that is used in Coder Journal, is my own creation.

What This Post Covers

This post is meant to provide an insight in to a technology, Reverse Proxy, that many developers are unaware of and it will be demonstrated through the eyes of my blog and how it works in regards to WordPress/IIS 6.0. Some of the basics will be covered such as the working of a URL Rewriter and Reverse Proxy. This post will not cover how to code a URL Rewriter or Reverse Proxy in C#. The reader should also have a basic understanding of how RegEx, HTTP, and URL Rewriters.

The Problem

On IIS 6.0, and previous versions, due to a lack of any standardized URL Rewriting process built in, so developers have to take nice visitor and SEO friendly URL’s like this:

http://www.coderjournal.com/2008/02/10/sample-post/

And make IIS 6.0 compatible ugly URL’s, which may or may not be SEO friendly, and neither URL is as visitor friendly as the one above.

http://www.coderjournal.com/?p=123
http://www.coderjournal.com/index.php/2008/02/10/sample-post/

My Solution Used On Coder Journal

The solution I choose was influenced by a number of factors, a couple that will change for the better when IIS 7.0 is released. The factors are:

  • I need to run PHP for WordPress.
  • I need to run FastCGI for IIS 6.0 to get the best performance out of PHP.
  • .NET and PHP run separate from each other, so I cannot use a .NET URL Rewriter to control which PHP file is chosen to run. (This changes in IIS 7.0 with Integrated Pipelines)
  • I need to pass all requests to www.coderjournal.com through .NET, which has a performance loss for rendering static files such as image, and text files. (This changes in IIS 7.0 with Integrated Pipelines)
  • I need to keep the URL’s friendly for visitors and SEO.

So because of what I listed above I needed to create two web servers to host www.coderjournal.com, which I will talk about later on in this article. One of the servers is the public interface to www.coderjournal.com, which I will call frontend, and the other is the Backend WordPress web server, which I will call backend that only handles standard WordPress with the ugly URL’s listed above, this one is not public. The picture will demonstrate the structure better than I can explain.

Coder Journal Web Structure

As you can see, from the above picture, all requests to WordPress are handled by the frontend server for this blog. This all happens through a technique known as Reverse Proxy.

A reverse proxy dispatches in-bound network traffic to a set of servers, presenting a single interface to the caller. For example, a reverse proxy could be used for load balancing a cluster of web servers. In contrast, a forward proxy acts as a proxy for out-bound traffic. For example, an ISP may use a proxy to forward HTTP traffic from its clients to external web servers on the internet; it may also cache the results to improve performance.

So with out going in to a deep explanation of how I was able to accomplish the reverse proxy, basically for every request that comes in to frontend server that meets a certain criteria I make another HTTP web request to the backend server and then write it’s response back to the original frontend server request.

Step 1 - Setting Up .NET to Process All Requests

Setup your frontend server to process everything through the .NET framework.

  1. Open IIS and right-click on the website and select Properties.
  2. Click the Configuration button under Application Settings section
  3. Click the Insert… button to create a new wildcard mapping
  4. Set the executable textbox to aspnet_isapi.dll file location.
    for .net 2.0, 3.0, 3.5: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
  5. Make sure the checkbox Verify that file exists is not checked.
  6. Press OK to confirm and close all the windows.

Step 2 - Install PHP/WordPress

Just follow this article on IIS.NET for installing PHP/WordPress on IIS 6.0. You may also want to install FastCGI, I recommend this, but it is optional.

Step 3 - Setting Up the URL Rewriter and Reverse Proxy Rules

The criteria for the requests are put inside the URL Rewriter Rules files. But before the proxy request is made, I must check to make sure the file being requested doesn’t already exist on the frontend server. If it does exist on the frontend server I don’t want to make a reverse proxy request. The following is the code used to do that.

# any file that exists just return it
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*) $1 [L]

Then after I check to make sure the file doesn’t exist on the frontend server I make the request to the backend using the following rules.

# proxy all connections through to the backend server
RewriteRule ^(/[0-9]{4}/.*) http://backend/index.php$1 [P]
RewriteRule ^(/tags/.*) http://backend/index.php$1 [NC,P]
RewriteRule ^(/topics/.*) http://backend/index.php$1 [NC,P]
RewriteRule ^(/author/.*) http://backend/index.php$1 [NC,P]
RewriteRule ^(/comments/feed/.*) http://backend/index.php$1 [NC,P]
RewriteRule ^(/page/.*) http://backend/index.php$1 [NC,P]
RewriteRule ^(.*) http://backend$1 [P]

Conclusions

To get the exact same setup as I have, you will need the following software, which is all free for download:

As always if you have any questions about the setup or the performance please post them below in the comments and I will answer them and or update the post as needed.

Happy Coding.

Tags: , , , , , , , , , ,

Posted in ASP.NET, C#, How To, SEO | kick it on DotNetKicks.com | Bookmark | View blog reactions | 1 Comment »