Bring the world of dynamic coding with IronPython and ASP.Net MVC together.
C# Python Other
Latest commit 458e717 Feb 25, 2016 @simplicbe simplicbe Update
Failed to load latest commit information.


Create AspNet MVC based websites and applications with IronPython to combine the power of the .Net Framework and Python.

The following things are currently supported:

  1. Application Startup
  2. Creating controller and actions
  3. Using different layout techniques
  4. Use bundles for embedding Script and Styles
  5. Use method decorators for routing and http-method filter
  6. Base implementation of the filter system

Simple example

This example shows some very basic usage. It creates an application and one Home controller which will be registered automatically.

# ------------------------------------------------
# This is the root of any IronPython based
# AspNet MVC application.
# ------------------------------------------------

import aspnet

# Define "root" class of the MVC-System
class App(aspnet.Application):

    # Start IronPython mvc application. 
    # Routes and other stuff can be registered here
    def start(self):

        # Register all routes

        # Set layout

class HomeController(aspnet.Controller):

    def index(self):
        return self.view("~/Views/Home/Index.cshtml")

Creating a controller

For creating a controller, just let your class derive from aspnet.Controller:

class ProductController(aspnet.Controller):

    # Index endpoint which is available over:
    def index(self):
        return self.view()

All controller can be automatically registered using: aspnet.Routing.register_all() on application startup.

Making a action accepts only post

To make an action only accept post request, just use the httpPost decorator:

class ProductController(aspnet.Controller):

    def add(self, model):
        # ....


Register bundles to load them in your views:

# Load style bundle
bundle = aspnet.StyleBundle('~/Content/css')