Cookie policy

By default we only use technical cookies.
session is our cookie to store your HTTP session variables

Privacy policy

Honestly, I have not enough time, money and desire to care about who you are, your preferences about shopping, sex, religion or anything else.

Contacts

Not just a framework

I always called Netfluid has a "key application", it's not a "killer application", it will never break the market of application server but is a key application: it's built to build killer application.
So i wrote some API and services in few minutes

API

Scrappy - HTML5 semantic markup scraper

Extract any schema.org sematic microdata elements into an easy, readable json format

Microdata is a collection of schemas that webmasters can use to markup HTML pages in ways recognized by major search providers, and that can also be used for structured data interoperability like in the case of Scrappy. Many sites are generated from structured data, which is often stored in databases. When this data is formatted into HTML, it becomes very difficult to recover the original structured data. On-page markup enables Scrappy to understand the information on web pages, recover the sructured data and open a new road for new tools and applications that make use of the structure.

Loading..

GeoIP - High detailed geocoding

Query different services to tranform any ip address into highly detailed geographic position

Results

Need high volume queries?

GeoIP is also available on Mashape !

netfluid geoip is on mashape api marketplace

Api table

URL Method Parameters Results
http://netfluid.org/geoip/me GET Geocoded information of the calling ip address.
Useful for web pages
http://netfluid.org/geoip/:ip GET :ip Geocode a specific ip address

Services

Migrator - Move emails from a server to another

Netfluid framework

More powerful than ASP.NET, more simple than WCF

Netfluid is and open source framework to develop high performance web applications, designed and developed in the last six years by me and released under MIT license

An uncommon framework for uncommon application

Netfluid is not designed to run your own blog or "Hello world" websites, i worked for many years with php, asp, rails and ruby but i designed Netfluid to build what i cannot easily build with other frameworks.
So if you want to create websockets, web interfaced robotics, a mailinator clone or a RESTful database Netfluid is the answer, otherwise don't loose your time :D

Key features

  • Request filters: no matter what URL was asked, you can decide to stop the request and show a different result.Perfect for walled garden
  • Triggers: recieve a request, trig a threaded action. Perfect for counters and statics
  • Route by attribute: attach a method to an URL just by decorating it
  • Status code handlers: to handle errors with just a method
  • Absurd performance: Up to 30.000+ request/second, tested even against LOIC

Setting up the engine

Setting up the application server and start the web interface is absolutely simple.
The core of Netfluid framework is the static class Engine.
The Engine manage all HTTP/S related stuff, take requests, switch them to the right virtual host, invoke the right method and return the results to client.

NOTE: From version 5.0 Netfluid engine relays over HttpListener you may need administrator rights to run it and some "home edition" of windows there are OS limitation about the number of simultaneous clients.
On Windows Server editions, Mono, Linux, Android and OSX you can accept unlimited clients without any kind of limitation.


So the only thing that you need to do to start the application server is to tell him on wich prefixes it must listen and start to accecpt clients.
The simplest prefix is http://*/ wich means "serve any request on port 80, no matter wich hostnames was required"

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFluid;
namespace Example
{
                        class Program
    {
                        static void Main(string[] args)
        {
            Engine.Prefixes.Add("http://*/");
            Engine.Start();
        }
    }
}

Routes

Now we get our running application server, it's time making it works, the way is exposing methods to clients.
To expose methods to clients create a class that inherit MethodExposer and put some Route in it by decorating is methods with the attribute [Route] the Engine will do the rest.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFluid;
namespace Example
{
                        class SimpleExposer:MethodExposer
    {
        [Route("/")]
        IResponse HelloWord()
        {
                        return new StringResponse("Hi there ! I'm running Netfluid server :D");
        }
    }
    
                        class Program
    {
                        static void Main(string[] args)
        {
            Engine.Prefixes.Add("http://*/");
            Engine.Start();
        }
    }
}

In this way we assigned the method HelloWorld to uri / any other uri will go 404

Routes and parameters

Has any other C# methods even Netfluid exposed method can take parameters and has any other C# method all you have to do is to declare them, the Engine will automatically parse them by matching request variables and method parameters.
In this senseless example we got an html form wich have three fields: amount, username and password and a method wich take those parameters and make a very stupid credit charge to the user.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFluid;
namespace Example
{
                        class UseExposer:MethodExposer
    {
        [Route("/charge")]
        IResponse HelloWord(decimal amount, string username, string password)
        {
                        var user = Mongo.Database.Login(username, password);
                        if (user!=null)
            {
                user.AvailableCash += amount;
                user.Save();
                        return new StringResponse("OK");
            }
                        return new StringResponse("FAIL");
        }
    }
                        class Program
    {
                        static void Main(string[] args)
        {
            Engine.Prefixes.Add("http://*/");
            Engine.Start();
        }
    }
}
                    

Parameters in URL

Not always the parameters are from a POST request, sometimes they are in URL.
To handle in-url parameters we use the rails notation, into the Route attribute we mark the parameter with :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFluid;
namespace Example
{
                        class BlogExposer:MethodExposer
    {
        [Route("/blog/:year/:month")]
        JSONResponse ArticleApi(int year, int month)
        {
                        var post = Mongo.Database.BlogPost.Where(x=>x.Year == year && x.Month == month);
                        return new JSONResponse(post);
        }
    }
                        class Program
    {
                        static void Main(string[] args)
        {
            Engine.Prefixes.Add("http://*/");
            Engine.Start();
        }
    }
}

Differencing routes by request method

If not specified the route will listen on any kind of HTTP method, by the way many times is necessary to show different results on different request methods.
Instead of putting a big switch into the method you can assign a route to a specific HTTP method, like GET to show to show the login form and POST to elaborate the request.
In this example, a fake RESTful interface will can relative method on POST, GET, PUT and DELETE method.
The last method will handle request sent with other methods because theorically you can call the Netfluid engine with any HTTP method including CHICKEN
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFluid;
namespace Example
{
                        class RestExposer:MethodExposer
    {
        [Route("/:id","POST")]
                        public IResponse Create(string id)
        {
                        //insert something cool here
        }
        [Route("/:id","GET")]
                        public IResponse Read(string id)
        {
                        //insert something cool here
        }
        [Route("/:id","PUT")]
                        public IResponse Update(string id)
        {
                        //insert something cool here
        }
        [Route("/:id","DELETE")]
                        public IResponse Delete(string id)
        {
                        //insert something cool here
        }
        [Route("/:id")]
                        public IResponse Error(string id)
        {
            Response.StatusCode = StatusCode.NotAcceptable;
                        return new StringResponse(Request.HttpMethod+" is an invalid method");
        }
    }
                        class Program
    {
                        static void Main(string[] args)
        {
            Engine.Prefixes.Add("http://*/");
            Engine.Start();
        }
    }
}
                    

Routes parameters and complex types

Ok having primitive types parameter could be useful but if we want to build complex web application we need complex data types.
It's not problem ! :D
The only necessary stuff is to have a static method Parse(string) in your comple data types or a constructor wich takes a string as argument
                        using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NetFluid;
using System.Net.Mail;
namespace Example
{
                        class User
    {
                        /** User fields an properties ***/
                        public static User Parse(string id)
        {
                        //Take the user from database
        }
    }
                        class ComplexTypes:MethodExposer
    {
        [Route("/:user")]
                        public IResponse(User user)
        {
                        //insert something cool here
        }
        [Route("/:mail")]
                        public IResponse(MailAddress mail)
        {
                        //insert something cool here
        }
    }
}
                    

Filters

It's time to decide who can enter to our web application and who not.
Every time i wrote a web application i needed to wrote that code, many times repeating it in every fucking file.
So the first feature that i implemented into Netfluid are filters.
Filters are called every time someone make a request, no matter what.
And as the same of Route they can be added just by decorating the method with the proper attribute [Filter] and return a bool: if true stop the request flow otherwise anything goes as normal
class AnonStopper:MethodExposer
    {
        [Filter]
                        public bool StopNotLogged(ref IResponse resp)
        {
                        if (Session("user")==null)
            {
                resp = new MustacheTemplate("./UI/login.html");
                        return true;
            }
                        return false;
        }
    }

Filter options

A filter is a special kind of route, so it have Routes options like filtering request only on specific URLs or on specific methods
                        class AnonStopper:MethodExposer
    {
        [Filter("/admin")]
        public bool StopOnRoute(ref IResponse resp)
        {
            var user = Session<User>("user");
            if (user==null || !user.IsAdmin)
            {
                resp = new MustacheTemplate("./UI/login.html", new { error="you must be admin to access this area" });
                        return true;
            }
                        return false;
        }
        [Filter(url:null, method:"POST")]
        public bool StopOnMethod(ref IResponse resp)
        {
            var user = Session<User>("user");
            if (user == null)
            {
                resp = new MustacheTemplate("./UI/login.html", new { error = "only registered users can post contents" });
                        return true;
            }
                        return false;
        }
    }

Triggers

Sometimes is necessary to trigger some actions instead of showing a simple results.
Netfluid supports threads easily so you can launch a Task, a trigger is this just in a line of code.
A trigger works exactly as a Filter, by default is called on any request but you can set specific routes, regex or HTTP method
In this example, on any request the system save a server-side statistic about visitors
                        class Stats:MethodExposer
    {
        [Trigger]
        public void AddNew()
        {
            Mongo.Stat.Add(new 
            {
                Timestamp = DateTime.Now,
                IP = Request.RemoteEndPoint.Address,
                Uri = Request.Url.ToString(),
                Referrer = Request.UrlReferrer,
                Values = Context.Values
            });
        }
    }