In the summer I gave up trying to make my web server (on the internal Microsoft network) look perfect – and really I gave up on HTML and the complexity that went with it.
What I wanted was simple text formatting that didn’t require specialized tools and coincidentally I discovered Markdown: http://en.wikipedia.org/wiki/Markdown
And what I saw was a simple format – one mostly used for user input for forms. What I needed was something to help me in the role of an author of content.
Of course, it’s not as if one can create a text file called “default.markdown” and place it in your web server and have it all “Just Work” – have IIS read the markdown file and emit something browsers can display – HTML.
Or maybe this is possible ….
After installing the handler (simple), just create files in your web site with “.markdown” as the extension and IIS will translate it to HTML for browsers on-the-fly.
The heavy lifting was done for me when I found this library: http://www.brianjeremy.com/2007/12/07/revisied-markdownnet-library/
I freshened up the code with some .NET 3.5 goodness and generics and implemented a simple IIS7 handler that hooks it to IIS. The rest was just to add a bit of extra HTML to the output to handle document titles and refer to a stylesheet.
Available Here: http://sdrv.ms/1bgqyjO
Before you install the handler, you’ll see that the server in this example us serving HTML content from Default.htm
Download the ZIP file with the source code.
Open the MarkdownHandler solution with Visual Studio 2008
Compile the solution
in solution there’s a project called MarkdownHandler and inside it you’ll find two binaries are produced (Markdown.NET.dll and MarkdownHandler.dll)
Now start the IIS7 Management Console
Navigate to the Default Web Site
Right click on the Default Web Site and select Explore
And Explorer window will open to the location of the rot folder for this web site
This DLLs need to go into the bin directory. So, right click on the bin directory and select Open
Now copy those DLLs to this folder
And close the Explorer window
Navigate back to the Default Web Site
Right click on Handler Mappings and select Open Feature
You will see that there is no Markdown handler in the list. We will add one now.
In the Actions pane, Select Add Managed Handler
The Add Managed Handler dialog opens
For Request path enter “*.markdown”
Then for Type click the arrow to see the choices
“MarkdownHandler.MarkdownHandler” is listed because it is in the bin directory.
Select “MarkdownHandler.MarkdownHandler” .
For Name enter “Markdown”
Click on the Request Restrictions button
The Request Restrictions dialog launches
In the Mapping tab, click Invoke handle only if request is mapped to
For the Verbs tab – leave this one alone
On the Access tab you can leave it set to Script
Click OK to dismiss the dialog
Now in Handler Mappings you will see that the Markdown handler is enabled.
Now create a Default.markdown text file the root of your site
Mine looks something like this
And launch that page and you will see
And if you want you can change the default document to look for markdown files automatically …
So now I can just browse to the server and the default markdown is shown automatically