How To: Run ASP code and display results on a Blogger/Blogspot page! ~ Ask The Admin

Tuesday, September 11, 2007

How To: Run ASP code and display results on a Blogger/Blogspot page!

Hey folks,

Here at Ask The Admin we are very satisfied with our Blogger/Blogspot interface. It's streamlined, easy to use, fast, and is constantly buzzing with new features out of Google's Dev sector. However people such as myself, who are always into adding those extra spices into a site development project, are searching for ways to add various number-crunching, letter-parsing features. This could include anything from displaying the last 5 comments to a Blogger blog, such as we have on our info-bar to the right, to displaying a random quote, such as the one you see at the top of this blog under the title graphic-bar thingy.

These features require data integration, even at it's simplest form (the random quote uses 1 table with a few columns in a MySQL database running on a different server). This would require a host with, at least, a DB server, such as MySQL, and a server side scripting engine, such as Microsoft IIS with ASP, or Apache with PHP. I've seen evidence that, in the past, Google has offered a pay service where Blogspot bloggers could have ftp access to their blog, thereby being able to control the page extension. Once you change the page extension from .html to .asp, you are able to see, at the very least, whether the server your blog is running on can parse ASP code. If ASP doesn't work, the next logical step would be to see if the server in question can handle PHP code by renaming the page extension to php and replacing the ASP code with PHP. Once you establish either ASP or PHP capability you're home free in terms of feature potential. The possibilities are endless as to how much free, totally open-source code there is floating around the intermanet pipes.

ASP and Javascript are my client-server codes of choice. Since I can't have Google host my MySQL database, I need to have that hosted on one of our hosting accounts at GoDaddy. And since it is not uncommon to have a web application on one host request information from a database on another host, I didn't expect any issues with that part of it. It was the processing of server-side code, like ASP or PHP, that blogger wouldn't allow me to do. After much research and digging, I've found that blogger tends to either replace characters in Client Side scripts, thus breaking the script, or in the case of Server Side code, it will just spit it back at you, having not compiled it because of the inherent page extension of .html that google's pages use by default.
I can't change page extensions to compile some server side goodness, and I don't have ftp access to our Blogger Blog to upload a file. So that means the file responsible for spitting out the results I need, has to be hosted on another server as well. When I attempted to perform a server side include, the include worked, however it would spit out the included page's code onto my sandbox site, instead of the compiled result. This led me to search for another way around this.
The elegantly simple, cross-browser compatible, fully-configurable solution I found was the HTML IFrame. What a beautiful piece of work. This singular HTML object carries the task of bringing one site's compiled content into play on another site. Pure philanthropy (cue We Are The World music). Bringing the world together 1 line of code at a time. (cue Got Milk commercial). The Iframe allowed me to bring in the compiled results off of an ASP page on our GoDaddy web host, which in turn, pulled data from the MySQL database that was included (FREE, we love that) with our hosting account. WHO's BETTER THAN US?

For now this yields a quirky little random quote generator at the top of our much adored blog site. But this opens up the potential to allow data integration into the Blogosphere realm, without the need for WordPress. Now I'm not sure how this affected any attached CSS styles, all I can see is that they are not affecting the text. The quick remedy for that was some inline css and the self-made, externally hosted Blogger widget was complete. Now mind you, I did not write the code for the Quote generator. That was written by the guys and gals over at And there are alot of others like it. The last thing I did was add the iframe code into a HTML/Javascript widget on Blogger and poof! Fully scriptable goodness. And it was free (for the most part, no thanks to GoDaddy). Just the way we like it here on .


Commodore 64 (The one you used to play Bruce Lee on)