Simplify.Web is an open-source, lightweight and fast server-side .NET web-framework based on ASP.NET Core for building HTTP based web-applications, RESTful APIs etc.
Framework can be used as:
Can be hosted:
There is a templates package available at nuget.org for Simplify.Web. It contains a couple of templates which can be a good starting point for your application.
Installing a templates package:
dotnet new -i Simplify.Web.Templates
Template | Short Name |
---|---|
Angular template | sweb.angular |
Api template | sweb.api |
Minimal template | sweb.minimal |
Windows service hosted api template | sweb.api.windowsservice |
Use the short name to create a project based on selected template:
dotnet new sweb.angular -n HelloWorldApplication
Then just run project via F5 (it will download all required nuget and npm packages at first build).
[Get("api/v1/weatherTypes")]
public class SampleDataController : Controller
{
private static readonly string[] Summaries =
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
public override ControllerResponse Invoke()
{
try
{
return new Json(items);
}
catch (Exception e)
{
Console.WriteLine(e);
return StatusCode(500);
}
}
}
[Post("api/v1/sendMessage")]
public class SampleDataController : Controller<SampleModel>
{
public override ControllerResponse Invoke()
{
try
{
Trace.WriteLine($"Object with message received: {Model.Message}");
return NoContent();
}
catch (Exception e) when (e is ModelValidationException || e is Newtonsoft.Json.JsonException)
{
return StatusCode(400, e.Message);
}
catch (Exception e)
{
Console.WriteLine(e);
return StatusCode(500, "Site error!");
}
}
}
public class SampleModel
{
[Required]
public string Message { get; set; }
}
// Controller will be executed only on HTTP GET request like http://mysite.com/about
[Get("about")]
public class AboutController : Controller
{
public override ControllerResponse Invoke()
{
// About.tpl content will be inserted into {MainContent} in Master.tpl
return new StaticTpl("Static/About", StringTable.PageTitleAbout);
}
}
Runs on any request and adds login panel to a pages
// Controller will be executed on any request and will be launched before other controllers (because they have Priority = 0 by default)
[Priority(-1)]
public class LoginPanelController : AsyncController
{
public override async Task<ControllerResponse> Invoke()
{
return Context.Context.Authentication.User == null
// Data from GuestPanel.tpl will be inserted into {LoginPanel} in Master.tpl
? new InlineTpl("LoginPanel", await TemplateFactory.LoadAsync("Shared/LoginPanel/GuestPanel"))
// Data from LoggedUserPanelView will be inserted into {LoginPanel} in Master.tpl
: new InlineTpl("LoginPanel", await GetView<LoggedUserPanelView>().Get(Context.Context.Authentication.User.Identity.Name));
}
}
public class LoggedUserPanelView : View
{
public async Task<ITemplate> Get(string userName)
{
// Loading template from LoggedUserPanel.tpl asynchronously
var tpl = await TemplateFactory.LoadAsync("Shared/LoginPanel/LoggedUserPanel");
// Setting userName into {UserName} variable in LoggedUserPanel.tpl
tpl.Add("UserName", userName);
return tpl;
}
}
Below is the list of sample applications showing different variations of Simplify.Web usage:
There are many ways in which you can participate in the project. Like most open-source software projects, contributing code is just one of many outlets where you can help improve. Some of the things that you could help out with are:
Additional extensions to Simplify.Web live in their own repositories on GitHub. For example:
Licensed under the GNU LESSER GENERAL PUBLIC LICENSE