Homepage | About Me | Testing ASP.net Book | Best Blog Posts | Personal Projects | Follow me on Twitter | GitHub | SlideShare | RSS
Blog.BenHall.me.uk

Mono XSP == OSX ASP.net Web Server

Tuesday, September 22, 2009
Over the weekend I required a very simple web server on my MacBook to allow me to play around with some iPhone Web App development. It didn't need to do much, simply accept requests and serve webpages. While I've created web servers before, after sending a tweet out I was reminded about Mono XSP. XSP is an ASP.net web server developed under the Mono project banner allowing you to serve web pages and asserts (javascript, css, images etc) to clients. Simply - it's great! After installing Mono, to launch a server simply navigate to the directory where your pages resides using a Terminal (command prompt), and type in XSP. This will start a full webserver on port 8080 serving pages from the directory. Now, within seconds, I can quickly make any directory on my laptop accessible over HTTP! On OSX, the execution simply looks like this: Pretty:Base Ben$ xsp
xsp2
Listening on address: 0.0.0.0
Root directory: /Users/Ben/SourceControl/iPhoneWebApp101/iWebKit/Base
Listening on port: 8080 (non-secure)
Hit Return to stop the server.

Great for prototyping and rapid development and while I haven't tried it, it should work on Windows equally as well.

Labels:

Mono and File Paths

Friday, August 15, 2008

The joy of developing cross platform applications!!

When dealing with files and paths on a windows based platform you always use a backslash (\) as the path separator, for example 'Config\Settings.xml'. Append the full path onto the beginning and you would be able to load the settings.  However, if your application needs to run on top Linux or Mac OS X (Mono) then file paths are slightly different. Instead of 'Config\Settings.xml' you need to use 'Config/Settings.xml'. Notice the all important forward slash (/)! It's a simple mistake to make and it can take a few moments to realise what the problem is. 

If you wanted to be really hard core (and correct), you would use Path.DirectorySeparatorChar property to define your separator. Alternatively, you might want to look at IOMap which should solve this mismatch problem for you.

Variations like this is a great reason why you should run your unit\integration tests on both platforms as part of your build.

Technorati Tags:

Labels: