Simplify.Web
4.4.3
See the version list below for details.
dotnet add package Simplify.Web --version 4.4.3
NuGet\Install-Package Simplify.Web -Version 4.4.3
<PackageReference Include="Simplify.Web" Version="4.4.3" />
paket add Simplify.Web --version 4.4.3
#r "nuget: Simplify.Web, 4.4.3"
// Install Simplify.Web as a Cake Addin
#addin nuget:?package=Simplify.Web&version=4.4.3
// Install Simplify.Web as a Cake Tool
#tool nuget:?package=Simplify.Web&version=4.4.3
Simplify.Web
Simplify.Web is an open-source, lightweight and fast server-side .NET web-framework based on MVC and OWIN patterns for building HTTP based web-applications, RESTful APIs etc.
Framework can be used as:
- An API backend framework
- As a mix of API backend + some SPA front end like Angular
- As an old way backend generated web-site
Can be hosted:
- The same way as an ApsNetCore MVC application (On IIS, or as a console application)
- Inside a windows service
Main features
- Comes as Microsoft.AspNetCore middleware
- Can be used as an API backend only with front-end frameworks
- Based on MVC and MVVM patterns
- Lightweight & Fast
- Uses switchable IOC container for itself and controllers, views constructor injection (Simplify.DI)
- Support async controllers
- Supports controllers which can be run on any request
- Localization-friendly (supports templates, strings and data files localization by default)
- Uses fast templates engine (Simplify.Templates)
- Mocking-friendly
- Mono-friendly
Quick start
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).
Detailed documentation
API outgoing JSON controller example
[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);
}
}
}
API ingoing JSON controller example
[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; }
}
Some simple HTML generation controllers example
Static page controller
// 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);
}
}
Any page controller with high run priority example
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));
}
}
View example
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;
}
}
Example applications
Below is the list of sample applications showing different variations of Simplify.Web usage:
- Only as an API backend with Angular + Bootstrap UI SPA
- Simple Kestrel-based Application with backend page
- Kestrel-based Application with backend HTML generation, localization, authentication
- Only as an API backend with Vue.js + Bootstrap UI SPA
- Only as an API backend with Vue.js + Element UI SPA
- Simple Kestrel-based Application hosted as windows-service
Contributing
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:
- Documentation (both code and features)
- Bug reports
- Bug fixes
- Feature requests
- Feature implementations
- Test coverage
- Code quality
- Sample applications
Related Projects
Additional extensions to Simplify.Web live in their own repositories on GitHub. For example:
- Simplify.Web.Json - JSON serialization/deserialization
- Simplify.Web.Multipart - multipart form model binder
- Simplify.Web.MessageBox - non-interactive server side message box
- Simplify.Web.Templates - Visual studio project templates
License
Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETCoreApp 3.1
- Microsoft.CSharp (>= 4.7.0)
- Simplify.DI (>= 4.1.1)
- Simplify.Templates (>= 2.0.0)
-
.NETFramework 4.6.2
- Microsoft.AspNetCore.Hosting.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Configuration.Json (>= 3.1.20)
- Simplify.DI (>= 4.1.1)
- Simplify.Templates (>= 2.0.0)
-
.NETStandard 2.0
- Microsoft.AspNetCore.Hosting.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.Extensions.Configuration.Json (>= 3.1.20)
- Simplify.DI (>= 4.1.1)
- Simplify.Templates (>= 2.0.0)
-
net5.0
- Microsoft.CSharp (>= 4.7.0)
- Simplify.DI (>= 4.1.1)
- Simplify.Templates (>= 2.0.0)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Simplify.Web:
Package | Downloads |
---|---|
Simplify.Web.Json
Simplify.Web JSON controller response and model binder |
|
Simplify.Web.MessageBox
Simplify.Web static message box templates and controller response |
|
Simplify.Web.Multipart
Simplify.Web multipart form model binder |
|
Simplify.Web.Postman
Postman collection and environment generation extension for Simplify.Web |
|
Simplify.Web.Swagger
Swagger extensions for Simplify.Web web-framework |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.6.0 | 1,865 | 5/17/2022 |
4.5.1 | 908 | 4/27/2022 |
4.5.0 | 1,054 | 11/22/2021 |
4.4.3 | 321 | 10/19/2021 |
4.4.2 | 406 | 7/18/2021 |
4.4.1 | 300 | 7/6/2021 |
4.4.0 | 860 | 4/25/2021 |
4.3.0 | 314 | 4/22/2021 |
4.3.0-pre01 | 195 | 4/21/2021 |
4.2.3 | 1,252 | 2/27/2021 |
4.2.2 | 823 | 12/11/2020 |
4.2.1 | 889 | 10/23/2020 |
4.2.0 | 399 | 9/21/2020 |
4.1.2 | 594 | 8/26/2020 |
4.1.1 | 1,126 | 4/29/2020 |
4.1.0 | 433 | 4/1/2020 |
4.0.2 | 855 | 1/27/2020 |
4.0.1 | 499 | 1/6/2020 |
4.0.0 | 998 | 12/22/2019 |
4.0.0-pre01 | 555 | 12/17/2019 |
3.0.0 | 1,163 | 10/20/2019 |
2.3.0 | 966 | 9/28/2019 |
2.2.0 | 796 | 9/3/2019 |
2.1.0 | 821 | 8/22/2019 |
2.0.1 | 481 | 6/24/2019 |
2.0.0 | 998 | 1/1/2019 |
2.0.0-pre02 | 489 | 12/23/2018 |
2.0.0-pre01 | 504 | 12/18/2018 |
1.6.1 | 324 | 4/15/2022 |
1.6.0 | 514 | 9/28/2019 |
1.5.0 | 480 | 9/3/2019 |
1.4.1 | 509 | 6/25/2019 |
1.4.0 | 544 | 5/20/2019 |
1.3.0 | 622 | 12/16/2018 |
1.2.1 | 970 | 5/9/2018 |
1.2.0 | 1,519 | 8/23/2017 |
1.1.0 | 1,066 | 2/14/2017 |
1.0.1 | 2,083 | 8/26/2016 |
1.0.0 | 1,194 | 8/26/2016 |