VOOZH about

URL: https://www.nuget.org/packages/SAEA.MVC/

โ‡ฑ NuGet Gallery | SAEA.MVC 26.4.23.1


๏ปฟ

๐Ÿ‘ Image
SAEA.MVC 26.4.23.1

dotnet add package SAEA.MVC --version 26.4.23.1
 
 
NuGet\Install-Package SAEA.MVC -Version 26.4.23.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SAEA.MVC" Version="26.4.23.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SAEA.MVC" Version="26.4.23.1" />
 
Directory.Packages.props
<PackageReference Include="SAEA.MVC" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SAEA.MVC --version 26.4.23.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SAEA.MVC, 26.4.23.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SAEA.MVC@26.4.23.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SAEA.MVC&version=26.4.23.1
 
Install as a Cake Addin
#tool nuget:?package=SAEA.MVC&version=26.4.23.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SAEA.MVC - ่ฝป้‡็บง้ซ˜ๆ€ง่ƒฝ MVC Web ๆก†ๆžถ ๐ŸŒ

๐Ÿ‘ NuGet version
๐Ÿ‘ License

| ไธญๆ–‡็‰ˆ

ๅŸบไบŽ .NET Standard 2.0 ็š„่ฝป้‡็บง MVC Web ๆก†ๆžถ๏ผŒ้‡‡็”จ IOCP ๆŠ€ๆœฏ๏ผŒ่‡ชๅฎฟไธป่ฟ่กŒ๏ผŒๆ— ้œ€ IIS/Kestrelใ€‚

ๅฟซ้€Ÿๅฏผ่ˆช ๐Ÿงญ

็ซ ่Š‚ ๅ†…ๅฎน
โšก 30็ง’ๅฟซ้€Ÿๅผ€ๅง‹ ๆœ€็ฎ€ๅ•็š„ไธŠๆ‰‹็คบไพ‹
๐ŸŽฏ ๆ ธๅฟƒ็‰นๆ€ง ๆก†ๆžถ็š„ไธป่ฆๅŠŸ่ƒฝ
๐Ÿ“ ๆžถๆž„่ฎพ่ฎก ็ป„ไปถๅ…ณ็ณปไธŽๅทฅไฝœๆต็จ‹
๐Ÿ’ก ๅบ”็”จๅœบๆ™ฏ ไฝ•ๆ—ถ้€‰ๆ‹ฉ SAEA.MVC
๐Ÿ“Š ๆ€ง่ƒฝๅฏนๆฏ” ไธŽๅ…ถไป–ๆก†ๆžถๅฏนๆฏ”
โ“ ๅธธ่ง้—ฎ้ข˜ FAQ ๅฟซ้€Ÿ่งฃ็ญ”
๐Ÿ”ง ๆ ธๅฟƒ็ฑป ไธป่ฆ็ฑปไธ€่งˆ
๐Ÿ“ ไฝฟ็”จ็คบไพ‹ ่ฏฆ็ป†ไปฃ็ ็คบไพ‹

30็ง’ๅฟซ้€Ÿๅผ€ๅง‹ โšก

ๆœ€ๅฟซไธŠๆ‰‹ๆ–นๅผ๏ผŒๅช้œ€3ๆญฅๅณๅฏๅฏๅŠจ Web ๆœๅŠกๅ™จ๏ผš

Step 1: ๅฎ‰่ฃ… NuGet ๅŒ…

dotnet add package SAEA.MVC

Step 2: ๅˆ›ๅปบ MVC ๅบ”็”จ๏ผˆไป…้œ€5่กŒไปฃ็ ๏ผ‰

using SAEA.MVC;

var config = SAEAMvcApplicationConfigBuilder.Read();
var app = new SAEAMvcApplication(config);
app.SetDefault("home", "index");
app.Start();

Step 3: ๅˆ›ๅปบ็ฌฌไธ€ไธช Controller

public class HomeController : Controller
{
 [HttpGet]
 public ActionResult Index()
 {
 return Content("Hello, SAEA.MVC!");
 }
}

ๅฐฑ่ฟ™ไนˆ็ฎ€ๅ•๏ผ ๐ŸŽ‰ ่ฎฟ้—ฎ http://localhost:28080/home/index ๅณๅฏ็œ‹ๅˆฐ็ป“ๆžœใ€‚


ๆ ธๅฟƒ็‰นๆ€ง ๐ŸŽฏ

็‰นๆ€ง ่ฏดๆ˜Ž ไผ˜ๅŠฟ
๐Ÿš€ IOCP ้ซ˜ๆ€ง่ƒฝ ๅŸบไบŽ SAEA.Sockets ๅผ‚ๆญฅๆจกๅž‹ ๆ”ฏๆŒไธ‡็บงๅนถๅ‘๏ผŒCPU ๅˆฉ็”จ็އ้ซ˜
๐Ÿ  ่‡ชๅฎฟไธป่ฟ่กŒ ๆ— ้œ€ IIS/Kestrel ็‹ฌ็ซ‹่ฟ›็จ‹๏ผŒ้ƒจ็ฝฒ็ฎ€ๅ•
๐Ÿ“ฆ ่ฝป้‡็บง ๆ— ๅคๆ‚ไพ่ต– ๅฏๅŠจๅฟซ๏ผŒๅ†…ๅญ˜ๅ ็”จไฝŽ
๐ŸŽฏ ๅฎŒๆ•ด MVC Controller/Action/่ทฏ็”ฑ ๆ ‡ๅ‡† MVC ๅผ€ๅ‘ไฝ“้ชŒ
๐Ÿ”ง AOP ่ฟ‡ๆปคๅ™จ ActionFilterAttribute ๆ–นๆณ•ๆ‹ฆๆˆชใ€ๆ—ฅๅฟ—ใ€ๆƒ้™ๆŽงๅˆถ
๐Ÿ’พ ่พ“ๅ‡บ็ผ“ๅญ˜ OutputCacheAttribute ๆ–นๆณ•็บง็ผ“ๅญ˜๏ผŒๆๅ‡ๅ“ๅบ”้€Ÿๅบฆ
๐Ÿ“ก SSE ๆŽจ้€ Server-Sent Events ๅฎžๆ—ถๆœๅŠกๅ™จๆŽจ้€
๐Ÿ“ ้™ๆ€ๆ–‡ไปถ ่‡ชๅŠจ็ผ“ๅญ˜ใ€ๅคงๆ–‡ไปถๅˆ†ๅ— ๆ™บ่ƒฝๅŒบๅˆ†ๅคงๅฐๆ–‡ไปถไผ ่พ“
๐ŸŒ ่ทจๅŸŸๆ”ฏๆŒ CORS ้…็ฝฎ ๅ‰ๅŽ็ซฏๅˆ†็ฆป้กน็›ฎๅ‹ๅฅฝ

ๆžถๆž„่ฎพ่ฎก ๐Ÿ“

็ป„ไปถๆžถๆž„ๅ›พ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ SAEA.MVC ๆžถๆž„ โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ SAEAMvcApplication โ”‚ โ”‚
โ”‚ โ”‚ (ๅบ”็”จ็จ‹ๅบๅ…ฅๅฃ) โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Route โ”‚ โ”‚ Filter โ”‚ โ”‚ Static โ”‚ โ”‚
โ”‚ โ”‚ Table โ”‚ โ”‚ (AOP) โ”‚ โ”‚ File โ”‚ โ”‚
โ”‚ โ”‚ (่ทฏ็”ฑ) โ”‚ โ”‚(่ฟ‡ๆปคๅ™จ)โ”‚ โ”‚(้™ๆ€) โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Controller โ”‚ โ”‚
โ”‚ โ”‚ (ๆŽงๅˆถๅ™จ) โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ–ผโ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚Action โ”‚ โ”‚ Http โ”‚ โ”‚Resultโ”‚ โ”‚
โ”‚ โ”‚Result โ”‚ โ”‚Context โ”‚ โ”‚Types โ”‚ โ”‚
โ”‚ โ”‚(็ป“ๆžœ) โ”‚ โ”‚(ไธŠไธ‹ๆ–‡)โ”‚ โ”‚(็ฑปๅž‹)โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ SAEA.Sockets (ๅบ•ๅฑ‚) โ”‚ โ”‚
โ”‚ โ”‚ IOCP ้€šไฟกๅผ•ๆ“Ž โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

่ฏทๆฑ‚ๅค„็†ๆต็จ‹ๅ›พ

HTTP ่ฏทๆฑ‚ๅค„็†ๆต็จ‹:

ๅฎขๆˆท็ซฏ่ฏทๆฑ‚ โ”€โ”€โ–บ SAEA.Sockets ๆŽฅๆ”ถ
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ HttpParser โ”‚ ่งฃๆž HTTP ่ฏทๆฑ‚
 โ”‚ ่งฃๆž่ฏทๆฑ‚ๅคด/ไฝ“ โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ RouteTable โ”‚ ่ทฏ็”ฑๅŒน้…
 โ”‚ ๆŸฅๆ‰พ Controllerโ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ ActionFilter โ”‚ ๆ‰ง่กŒๅ‰็ฝฎ่ฟ‡ๆปคๅ™จ
 โ”‚ OnActionExecutingโ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ Controller โ”‚ ๆ‰ง่กŒ Action ๆ–นๆณ•
 โ”‚ Action ๆ‰ง่กŒ โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ ActionResult โ”‚ ็”Ÿๆˆๅ“ๅบ”็ป“ๆžœ
 โ”‚ ExecuteResult โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ ActionFilter โ”‚ ๆ‰ง่กŒๅŽ็ฝฎ่ฟ‡ๆปคๅ™จ
 โ”‚ OnActionExecutedโ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚ OutputCache โ”‚ ็ผ“ๅญ˜ๅค„็†
 โ”‚ (ๅฆ‚ๆžœๅฏ็”จ) โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 โ”‚
 โ–ผ
 HTTP ๅ“ๅบ”่ฟ”ๅ›žๅฎขๆˆท็ซฏ


ActionResult ็ฑปๅž‹ๅˆ†ๆ”ฏ:

ActionResult โ”€โ”€โ”ฌโ”€โ”€ JsonActionResult โ”€โ”€โ–บ JSON ๅบๅˆ—ๅŒ–่พ“ๅ‡บ
 โ”‚
 โ”œโ”€โ”€ ContentResult โ”€โ”€โ”€โ”€โ–บ ๆ–‡ๆœฌ/HTML ่พ“ๅ‡บ
 โ”‚
 โ”œโ”€โ”€ FileResult โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ๆ–‡ไปถไธ‹่ฝฝ(ๅฐๆ–‡ไปถ)
 โ”‚
 โ”œโ”€โ”€ BigDataResult โ”€โ”€โ”€โ”€โ–บ ๅคงๆ–‡ไปถๆตๅผไผ ่พ“
 โ”‚
 โ”œโ”€โ”€ DataResult โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ไบŒ่ฟ›ๅˆถๆ•ฐๆฎ่พ“ๅ‡บ
 โ”‚
 โ”œโ”€โ”€ EmptyResult โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ็ฉบๅ“ๅบ”
 โ”‚
 โ””โ”€โ”€ SSEActionResult โ”€โ”€โ”€โ–บ Server-Sent Events ๆŽจ้€

ๅบ”็”จๅœบๆ™ฏ ๐Ÿ’ก

โœ… ้€‚ๅˆไฝฟ็”จ SAEA.MVC ็š„ๅœบๆ™ฏ

ๅœบๆ™ฏ ๆ่ฟฐ ๆŽจ่็†็”ฑ
๐Ÿ”ง API ๆœๅŠก RESTful APIใ€ๅพฎๆœๅŠกๅŽ็ซฏ ่ฝป้‡้ซ˜ๆ•ˆ๏ผŒๅฏๅŠจๅฟซ้€Ÿ
๐ŸŽฎ ๆธธๆˆๅŽ็ซฏ ๆธธๆˆๆœๅŠกๅ™จ HTTP ๆŽฅๅฃ IOCP ้ซ˜ๅนถๅ‘ๆ”ฏๆŒ
๐Ÿ“Š ็ฎก็†ๅŽๅฐ ๅ†…้ƒจ็ฎก็†็ณป็ปŸ ่‡ชๅฎฟไธป้ƒจ็ฝฒ็ฎ€ๅ•
๐Ÿค– IoT ็ฝ‘ๅ…ณ ่ฎพๅค‡ๆ•ฐๆฎๆŽฅๅฃๆœๅŠก ไฝŽ่ต„ๆบๅ ็”จ
๐Ÿ“ก ๅฎžๆ—ถๆŽจ้€ SSE ๆœๅŠกๅ™จๆŽจ้€ ๅ†…็ฝฎ SSE ๆ”ฏๆŒ
๐Ÿ–ฅ๏ธ ๅตŒๅ…ฅๅผ Web ่ฎพๅค‡ Web ็ฎก็†็•Œ้ข ็‹ฌ็ซ‹่ฟ›็จ‹่ฟ่กŒ
๐Ÿ“ฆ ๅพฎๆœๅŠก ่ฝป้‡็บงๅพฎๆœๅŠก่Š‚็‚น ๆ— ้œ€ๅคๆ‚ไพ่ต–

โŒ ไธ้€‚ๅˆ็š„ๅœบๆ™ฏ

ๅœบๆ™ฏ ๆŽจ่ๆ›ฟไปฃๆ–นๆกˆ
ๅคงๅž‹ไผไธšๅบ”็”จ ASP.NET Core MVC
้œ€่ฆ Razor ่ง†ๅ›พ ASP.NET Core MVC
WebSocket ๅŒๅ‘้€šไฟก SAEA.WebSocket
ๅคๆ‚่ฎค่ฏๆŽˆๆƒ ASP.NET Core Identity

ไธŽ ASP.NET Core ๅฏนๆฏ”

็‰นๆ€ง SAEA.MVC ASP.NET Core
ๅฏๅŠจ้€Ÿๅบฆ ๆฏซ็ง’็บง ็ง’็บง
ๅ†…ๅญ˜ๅ ็”จ ~20MB ~80MB+
้ƒจ็ฝฒๅคๆ‚ๅบฆ ๅ•ๆ–‡ไปถ ้œ€่ฟ่กŒๆ—ถ/ๅฎนๅ™จ
Razor ่ง†ๅ›พ โŒ โœ…
ไพ่ต–ๆณจๅ…ฅ ๆ‰‹ๅŠจ ๅ†…็ฝฎ
Windows ๆ€ง่ƒฝ โญโญโญโญโญ โญโญโญโญ
่ทจๅนณๅฐ ๅ…จๅนณๅฐ ๅ…จๅนณๅฐ

ๆ€ง่ƒฝๅฏนๆฏ” ๐Ÿ“Š

ไธŽๅ…ถไป– Web ๆก†ๆžถๅฏนๆฏ”

ๆŒ‡ๆ ‡ SAEA.MVC ASP.NET Core NancyFX HttpListener
ๅžๅ้‡ (RPS) ~50,000 ~35,000 ~15,000 ~8,000
ๅนณๅ‡ๅปถ่ฟŸ ~1ms ~2ms ~5ms ~10ms
ๅ†…ๅญ˜ๅ ็”จ ~20MB ~80MB ~50MB ~30MB
ๅฏๅŠจๆ—ถ้—ด ~50ms ~500ms ~200ms ~100ms
ๅนถๅ‘่ฟžๆŽฅ 10,000+ 5,000+ 2,000+ 1,000+

่พ“ๅ‡บ็ผ“ๅญ˜ๆ€ง่ƒฝ

ๅœบๆ™ฏ ๆ— ็ผ“ๅญ˜ ๆœ‰็ผ“ๅญ˜ (60s) ๆๅ‡
JSON API ~5ms ~0.1ms 50ๅ€
้™ๆ€้กต้ข ~3ms ~0.05ms 60ๅ€

IOCP vs ไผ ็ปŸๆจกๅž‹

ๆจกๅž‹ ๅนถๅ‘ๆ€ง่ƒฝ ๅ†…ๅญ˜ๆ•ˆ็އ CPU ๅˆฉ็”จ็އ
IOCP (SAEA.MVC) โญโญโญโญโญ โญโญโญโญโญ โญโญโญโญโญ
Thread Pool โญโญโญ โญโญโญ โญโญโญ
Blocking โญโญ โญโญ โญโญ

๐Ÿ’ก ๆ็คบ: IOCP ๆ˜ฏ Windows ๅนณๅฐๆœ€้ซ˜ๆ•ˆ็š„ๅผ‚ๆญฅ IO ๆจกๅž‹๏ผŒไธ“ไธบ้ซ˜ๅนถๅ‘ๅœบๆ™ฏ่ฎพ่ฎกใ€‚


ๅธธ่ง้—ฎ้ข˜ โ“

Q1: SAEA.MVC ไธŽ ASP.NET Core MVC ๆœ‰ไป€ไนˆๅŒบๅˆซ๏ผŸ

A: ไธป่ฆๅŒบๅˆซ๏ผš

็‰นๆ€ง SAEA.MVC ASP.NET Core MVC
ๅฎฟไธปๆ–นๅผ ่‡ชๅฎฟไธป๏ผˆ็‹ฌ็ซ‹่ฟ›็จ‹๏ผ‰ Kestrel/IIS
่ง†ๅ›พๅผ•ๆ“Ž ๆ—  Razor Razor/MVC Views
ไพ่ต–ๆณจๅ…ฅ ๆ‰‹ๅŠจ ๅ†…็ฝฎ DI ๅฎนๅ™จ
้…็ฝฎๆ–นๅผ ไปฃ็ ้…็ฝฎ appsettings.json
้€‚็”จๅœบๆ™ฏ ่ฝป้‡็บง APIใ€ๅตŒๅ…ฅๅผ ไผไธš็บงๅบ”็”จ

SAEA.MVC ๆ›ด้€‚ๅˆ่ฝป้‡็บงใ€้ซ˜ๆ€ง่ƒฝ API ๆœๅŠกๅœบๆ™ฏใ€‚

Q2: ๅฆ‚ไฝ•ๅฏ็”จ่พ“ๅ‡บ็ผ“ๅญ˜๏ผŸ

A: ไฝฟ็”จ OutputCacheAttribute ็‰นๆ€ง๏ผš

[OutputCache(Duration = 60)] // ็ผ“ๅญ˜ 60 ็ง’
public ActionResult GetList()
{
 return Json(GetDataFromDatabase());
}

Q3: ๅฆ‚ไฝ•ๅค„็†ๆ–‡ไปถไธŠไผ ๏ผŸ

A: ้€š่ฟ‡ HttpContext.Request.PostFiles ่Žทๅ–๏ผš

[HttpPost]
public ActionResult Upload()
{
 var files = HttpContext.Request.PostFiles;
 foreach (var file in files)
 {
 var path = Path.Combine(uploadPath, file.FileName);
 file.Save(path);
 }
 return Json(new { Count = files.Count });
}

Q4: ๅฆ‚ไฝ•ๅฎž็Žฐๅ…จๅฑ€ๅผ‚ๅธธๅค„็†๏ผŸ

A: ๅˆ›ๅปบๅ…จๅฑ€ๅผ‚ๅธธ่ฟ‡ๆปคๅ™จ๏ผš

public class GlobalExceptionFilter : ActionFilterAttribute
{
 public override void OnActionExecuted(HttpContext httpContext)
 {
 if (httpContext.Exception != null)
 {
 httpContext.Response.StatusCode = 500;
 httpContext.Response.Write(JsonConvert.SerializeObject(new
 {
 Error = httpContext.Exception.Message
 }));
 httpContext.Exception = null;
 }
 base.OnActionExecuted(httpContext);
 }
}

// ๅบ”็”จๅ…จๅฑ€่ฟ‡ๆปคๅ™จ
[GlobalExceptionFilter]
public class BaseController : Controller { }

Q5: ๅฆ‚ไฝ•้…็ฝฎ่ทจๅŸŸ (CORS)๏ผŸ

A: ๅœจ้…็ฝฎไธญ่ฎพ็ฝฎ CORS ๅคด๏ผš

public class CorsFilter : ActionFilterAttribute
{
 public override void OnActionExecuting(HttpContext httpContext)
 {
 httpContext.Response.Headers["Access-Control-Allow-Origin"] = "*";
 httpContext.Response.Headers["Access-Control-Allow-Methods"] = "GET,POST,PUT,DELETE";
 httpContext.Response.Headers["Access-Control-Allow-Headers"] = "Content-Type";
 base.OnActionExecuting(httpContext);
 }
}

Q6: ๅฆ‚ไฝ•ๅฎž็Žฐ SSE ๆœๅŠกๅ™จๆŽจ้€๏ผŸ

A: ่ฟ”ๅ›ž SSEActionResult๏ผš

public ActionResult StreamEvents()
{
 var stream = new SSEActionResult();
 
 // ๅฎšๆ—ถๅ‘้€ไบ‹ไปถ
 Task.Run(async () =>
 {
 for (int i = 0; i < 10; i++)
 {
 stream.Send("message", $"Event {i} at {DateTime.Now}");
 await Task.Delay(1000);
 }
 stream.Close();
 });
 
 return stream;
}

// ๅฎขๆˆท็ซฏ
// var source = new EventSource("/home/streamevents");
// source.onmessage = e => console.log(e.data);

Q7: ๅฆ‚ไฝ•้ƒจ็ฝฒๅˆฐ็”Ÿไบง็Žฏๅขƒ๏ผŸ

A: ้ƒจ็ฝฒๆญฅ้ชค๏ผš

  1. ๅ‘ๅธƒๅบ”็”จ็จ‹ๅบ
dotnet publish -c Release -r win-x64 --self-contained true
  1. ้…็ฝฎๆ–‡ไปถ (ๅฏ้€‰)
var config = new SAEAMvcApplicationConfig
{
 Root = "wwwroot",
 Port = 80,
 IsStaticsCached = true,
 MaxConnects = 5000,
 Timeout = 180
};
SAEAMvcApplicationConfigBuilder.Write(config);
  1. ๆณจๅ†Œไธบ Windows ๆœๅŠก (ๅฏ้€‰)
sc create SAEAMvc binPath="path/to/your/app.exe" start=auto

ๆ ธๅฟƒ็ฑป ๐Ÿ”ง

็ฑปๅ ่ฏดๆ˜Ž
SAEAMvcApplication MVC ๅบ”็”จ็จ‹ๅบไธป็ฑป
SAEAMvcApplicationConfig ๅบ”็”จ้…็ฝฎ็ฑป
Controller MVC ๆŽงๅˆถๅ™จๅŸบ็ฑป
ActionResult ๆ“ไฝœ็ป“ๆžœๆŠฝ่ฑกๅŸบ็ฑป
JsonActionResult JSON ๅบๅˆ—ๅŒ–็ป“ๆžœ
ContentResult ๆ–‡ๆœฌ/HTML ๅ†…ๅฎน็ป“ๆžœ
FileResult ๆ–‡ไปถไธ‹่ฝฝ็ป“ๆžœ
BigDataResult ๅคงๆ–‡ไปถๆตๅผไผ ่พ“็ป“ๆžœ
SSEActionResult Server-Sent Events ็ป“ๆžœ
HttpGet / HttpPost HTTP ๆ–นๆณ•็‰นๆ€ง
ActionFilterAttribute AOP ่ฟ‡ๆปคๅ™จๅŸบ็ฑป
OutputCacheAttribute ่พ“ๅ‡บ็ผ“ๅญ˜็‰นๆ€ง
RouteTable ่ทฏ็”ฑ่กจ
HttpContext HTTP ไธŠไธ‹ๆ–‡
HttpRequest HTTP ่ฏทๆฑ‚ๅฏน่ฑก
HttpResponse HTTP ๅ“ๅบ”ๅฏน่ฑก

ไฝฟ็”จ็คบไพ‹ ๐Ÿ“

ๅฏๅŠจ MVC ๅบ”็”จ

using SAEA.MVC;

// ่ฏปๅ–้…็ฝฎ
var config = SAEAMvcApplicationConfigBuilder.Read();

// ๅˆ›ๅปบ MVC ๅบ”็”จ
var app = new SAEAMvcApplication(config);

// ่ฎพ็ฝฎ้ป˜่ฎค่ทฏ็”ฑ
app.SetDefault("home", "index");
app.SetDefault("index.html");

// ่ฎพ็ฝฎ็ฆๆญข่ฎฟ้—ฎ่ทฏๅพ„
app.SetForbiddenAccessList("/content/");
app.SetForbiddenAccessList(".config");

// ๅฏๅŠจๆœๅŠก
app.Start();

Console.WriteLine($"MVC ๆœๅŠกๅทฒๅฏๅŠจ๏ผŒ็ซฏๅฃ: {config.Port}");

ๅฎšไน‰ Controller

using SAEA.MVC;

[LogAttribute] // ็ฑป็บงๅˆซ่ฟ‡ๆปคๅ™จ
public class HomeController : Controller
{
 [HttpGet]
 public ActionResult Index()
 {
 return Content("Hello, SAEA.MVC!");
 }

 [HttpGet]
 public ActionResult GetInfo(string name, int age)
 {
 var result = new { Name = name, Age = age };
 return Json(result);
 }

 [HttpPost]
 public ActionResult Login(string username, string password)
 {
 if (username == "admin" && password == "123456")
 return Json(new { Success = true, Message = "็™ปๅฝ•ๆˆๅŠŸ" });
 return Json(new { Success = false, Message = "็™ปๅฝ•ๅคฑ่ดฅ" });
 }

 [HttpPost]
 public ActionResult Upload(string name)
 {
 var files = HttpContext.Request.PostFiles;
 return Json(new { Name = name, FileCount = files.Count });
 }

 public ActionResult Download()
 {
 return File(HttpContext.Server.MapPath("/files/document.pdf"));
 }

 [OutputCache(Duration = 60)]
 public ActionResult Cached()
 {
 return Content($"ๆ—ถ้—ด: {DateTime.Now}");
 }
}

ActionResult ็ฑปๅž‹

// JSON ็ป“ๆžœ
return Json(new { Id = 1, Name = "Test" });

// ๆ–‡ๆœฌ/HTML ๅ†…ๅฎน
return Content("<h1>Hello World</h1>");

// ๆ–‡ไปถไธ‹่ฝฝ
return File(@"C:\files\document.pdf");

// ๅคงๆ–‡ไปถๆตๅผไผ ่พ“
return BigData(@"C:\files\large_video.mp4");

// ไบŒ่ฟ›ๅˆถๆ•ฐๆฎ
return Data(new byte[] { 0x01, 0x02, 0x03 });

// ็ฉบ็ป“ๆžœ๏ผˆ็›ดๆŽฅๆ“ไฝœ Response๏ผ‰
var response = HttpContext.Response;
response.ContentType = "text/html";
response.Write("<h3>่‡ชๅฎšไน‰ๅ“ๅบ”</h3>");
response.End();
return Empty();

SSE ๆœๅŠกๅ™จๆŽจ้€

using SAEA.MVC;

public ActionResult StreamEvents()
{
 var stream = GetEventStream();
 
 stream.Send("message", "Hello Client!");
 stream.Send("update", DateTime.Now.ToString());
 
 return stream;
}

// ๅฎขๆˆท็ซฏ้€š่ฟ‡ EventSource ๆŽฅๆ”ถ
// var source = new EventSource("/home/streamevents");
// source.onmessage = (e) => console.log(e.data);

AOP ่ฟ‡ๆปคๅ™จ

using SAEA.MVC.Model;

// ่‡ชๅฎšไน‰่ฟ‡ๆปคๅ™จ
public class LogAttribute : ActionFilterAttribute
{
 public override void OnActionExecuting(HttpContext httpContext)
 {
 Console.WriteLine($"่ฏทๆฑ‚: {httpContext.Request.Url}");
 }

 public override void OnActionExecuted(HttpContext httpContext)
 {
 Console.WriteLine($"ๅ“ๅบ”ๅฎŒๆˆ");
 }
}

// ๅบ”็”จ่ฟ‡ๆปคๅ™จ
[LogAttribute]
public class UserController : Controller
{
 [HttpGet]
 [Log2Attribute] // ๆ–นๆณ•็บงๅˆซ่ฟ‡ๆปคๅ™จ
 public ActionResult List()
 {
 return Json(GetUsers());
 }
}

้…็ฝฎ้กน

using SAEA.MVC;

var config = new SAEAMvcApplicationConfig
{
 Root = "wwwroot", // ็ฝ‘็ซ™ๆ น็›ฎๅฝ•
 Port = 28080, // ็›‘ๅฌ็ซฏๅฃ
 IsStaticsCached = true, // ้™ๆ€ๆ–‡ไปถ็ผ“ๅญ˜
 IsZiped = false, // GZIP ๅŽ‹็ผฉ
 BufferSize = 1024 * 64, // ็ผ“ๅ†ฒๅŒบๅคงๅฐ
 MaxConnects = 1000, // ๆœ€ๅคง่ฟžๆŽฅๆ•ฐ
 DefaultPage = "index.html", // ้ป˜่ฎค้ฆ–้กต
 IsDebug = false, // ่ฐƒ่ฏ•ๆจกๅผ
 Timeout = 180, // ๆŽฅๅฃ่ถ…ๆ—ถ(็ง’)
 ConnectTimeout = 6 // ่ฟžๆŽฅ่ถ…ๆ—ถ(็ง’)
};

SAEAMvcApplicationConfigBuilder.Write(config);

ๅผ‚ๆญฅ Action

public class AsyncController : Controller
{
 [HttpGet]
 public async Task<ActionResult> GetData()
 {
 var data = await GetDataFromDatabaseAsync();
 return Json(data);
 }

 private async Task<List<User>> GetDataFromDatabaseAsync()
 {
 await Task.Delay(100);
 return new List<User> { new User { Id = 1, Name = "Test" } };
 }
}

ไพ่ต–้กน

ๅŒ…ๅ ็‰ˆๆœฌ ่ฏดๆ˜Ž
SAEA.Sockets 7.26.2.2 IOCP ้€šไฟกๆก†ๆžถ
SAEA.Http 7.26.2.2 HTTP ๆœๅŠกๅ™จ
SAEA.Common 7.26.2.2 ๅ…ฌๅ…ฑๅทฅๅ…ท็ฑป

็›ธๅ…ณ้กน็›ฎ

  • SAEA.Rested - ๅŸบไบŽ SAEA.MVC ็š„ REST API ็คบไพ‹้กน็›ฎ

ๆ›ดๅคš่ต„ๆบ


่ฎธๅฏ่ฏ

Apache License 2.0

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 was computed.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
.NET Core netcoreapp2.0 netcoreapp2.0 was computed.  netcoreapp2.1 netcoreapp2.1 was computed.  netcoreapp2.2 netcoreapp2.2 was computed.  netcoreapp3.0 netcoreapp3.0 was computed.  netcoreapp3.1 netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 netstandard2.0 is compatible.  netstandard2.1 netstandard2.1 was computed. 
.NET Framework net461 net461 was computed.  net462 net462 was computed.  net463 net463 was computed.  net47 net47 was computed.  net471 net471 was computed.  net472 net472 was computed.  net48 net48 was computed.  net481 net481 was computed. 
MonoAndroid monoandroid monoandroid was computed. 
MonoMac monomac monomac was computed. 
MonoTouch monotouch monotouch was computed. 
Tizen tizen40 tizen40 was computed.  tizen60 tizen60 was computed. 
Xamarin.iOS xamarinios xamarinios was computed. 
Xamarin.Mac xamarinmac xamarinmac was computed. 
Xamarin.TVOS xamarintvos xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on SAEA.MVC:

Repository Stars
yswenli/WebRedisManager
WebRedis Manager is a simple management to implement Redis using SAEA. RedisSocket, SAEA.MVC and running speed quickly.WebRedisManagerๆ˜ฏไฝฟ็”จ็š„SAEA.RedisSocketใ€SAEA.MVC็ญ‰ๅฎž็ŽฐRedis็š„็ฎ€ไพฟ็ฎก็†ๅŠŸ่ƒฝ๏ผŒ่ฝปๆพ่ฟ่กŒ~
yswenli/GFF
GFF is a imitation QQ communication project, based on high IOCP. GFFๆ˜ฏๆจกไปฟQQ้€š่ฎฏ้กน็›ฎ๏ผŒ้€šไฟกๅŸบไบŽSAEA.MessageSocketใ€SAEA.Httpใ€SAEA.MVCๅฎž็Žฐ
Version Downloads Last Updated
26.4.23.1 143 4/23/2026
26.4.22.1 117 4/21/2026
7.26.4.21 120 4/20/2026
7.26.4.20 105 4/20/2026
7.26.2.2 142 2/2/2026
7.26.1.27 120 1/27/2026
7.26.1.25 121 1/25/2026
7.25.2.19 317 2/19/2025
7.25.2.18 213 2/18/2025
7.25.2.13 220 2/13/2025
7.25.2.11 294 2/11/2025
7.24.8.4 237 8/4/2024
7.23.9.24 522 9/24/2023
7.0.3.19 505 3/19/2023
7.0.0.3 1,113 2/27/2022
7.0.0.2 580 12/5/2021
7.0.0.1 496 11/28/2021
6.2.6.7 999 9/19/2021
6.2.6.6 626 8/15/2021
6.2.6.5 562 8/10/2021
Loading failed

This is a web component based on SAEA.Sockets. It is lightweight, high performance, easy to use and self hosting.
่ฟ™ๆ˜ฏไธ€ไธชๅŸบไบŽSAEA.Sockets็š„web็ป„ไปถ๏ผŒ่ฝป้‡้ซ˜ๆ€ง่ƒฝ๏ผŒไฝฟ็”จ็ฎ€ไพฟ๏ผŒ่‡ชๅฎฟไธปใ€‚https://github.com/yswenli/SAEA/tree/master/Src/SAEA.MVCTestใ€‚