RailPhase is a lightweight web framework for .NET. It provides the tools necessary to write powerful web applications or embedded web servers in other applications.

Development time 2015-2016
Development duration 8 Months
Technologies C#
License MIT
Team size Single developer

RailPhase borrows some of the concepts from other frameworks like Ruby on Rails, but gives the user full control over the program execution without enforcing any design patterns. This makes it suited for embedded web applications, like a web GUI for a download manager.

However, RailPhase is also suited for full-scale web applications. In fact, this website is running on RailPhase. The nature of the .NET platform gives some performance advantages over other web frameworks. For example, the template system usually renders content about 10x faster than Django.

Usage Examples

The API of RailPhase is designed to be as simple as possible, reducing the time required to read the documentation before usage to a minimum.

This C# code starts a HTTP server on port 8080 that displays the current time and date on /time:

var app = new App();
app.AddStringView("^/time$", (context) => DateTime.Now.ToString());
app.RunHttpServer("http://localhost:8080/");

HTML content or other formats can be rendered with the template system. This HTML template takes a DateTime object as input and displays a nicely formatted web page:

<h1>The Year is {{Year}}.</h1>

<p>
  {% if Year % 4 == 0 && Year % 100 != 0 || Year % 400 == 0 %}
    This year is a leap year.
  {% endif %}
  The month is {{ Data.ToString("MMMM") }}.
  It has been {{Day}} days since the beginning of the month.
  Today is a {{ Data.ToString("dddd") }}.
</p>

This line tells the app to serve the template on the root URL, rendering DateTime.Now on every request:

app.AddStringView(
  "^/$", 
  context => Template.FromFile("DateTimeTemplate.html")(DateTime.Now, context)
);

The rendered result:

The Year is 2016. This year is a leap year. The month is July. It has been 30 days...

See more of my projects