Wiki

Clone wiki

LiteRpc.Server / Home

What is in the package?

The primary goal of this project was to facilitate using json-rpc protocol in MVC projects. You can freely add the package into your currently working MVC project and use currently written controllers as json-rpc exposers, with minor change.

Getting started

After adding the project, you can decorate any controller action you want to be exposed as json-rpc web service with a [Exposed] attribute. The only limitation is that you have to use json-rpc standard for output, that is, the result must be emitted using something like this:

return Json(new {result = myResult})

Easy huh? By the way, you have to obey json-rpc conventions when raising errors:

catch(Exception e)
{
    return Json(new {error = e.Message});
}

That is it! Keep in mind each json-rpc, according to the website, has to get a domain name, which we suppose the controller name, for example, if your controller is EducationController, the exposed json-rpc service domain name would be Education. As a result, if you have an action named GetStudentNumber, the resuling service port would make Education.GetStudentNumber.

Another feature of the library is the fact it can support authorization in two ways: Normal network credentials, i.e. unencrypted username and password, and standard cookie-based browser-like authentication. You can easily mark your action with standard [Authorize] attribute to make it accessible only to some people. Consequently, you must use FomrsAuthentication class methods to make the library understand the user is authenticated.

[Exposed]
public ActionResult Logon(string username, string password)
{
    //TODO: you favorite membership provider codes.
     FormsAuthentication.SetAuthCookie(username, false);
}

Updated