Googling all .NET articles
Push Notifications in .NET Core
https://github.com/tpeczek/Demo.AspNetCore.PushNotifications
Real-time in .NET Core:
http://gunnarpeipman.com/2018/01/aspnet-core-windows-iot-websocket/
Token in ASP.NET Core 2.0
https://jonhilton.net/2017/10/11/secure-your-asp.net-core-2.0-api-part-1---issuing-a-jwt/
GIT không có gì đáng sợ
https://viblo.asia/p/git-khong-co-gi-dang-so-yMnKMgMQl7P
Design Principles & Patterns
- Separation of Concern (MVC can do)
- Tight Coupling (MVC cannot do)
- Repository pattern
- Generic Repository pattern
- Unit of Work pattern
Authors
Bài học về sự kết hợp giữa Cookie-based Auth và Token-based Auth trong ứng dụng ASP.NET Core MVC
https://programmingwithmosh.com/
Bài học kinh nghiệm về thiết kế kiến trúc dự án
https://dotnetthoughts.net/ (Multi-tenant SaaS database tenancy patterns)
Bài học về design patterns
Blog in ASP.NET Core 2.0
https://github.com/HamidMosalla/FreelancerBlog
Multi tenant web applications
Samples
https://github.com/explorer14/JwtAuthenticationHelper
A simple Json Web Token authentication helper library that allows you to generate access tokens easily for both ASP.NET Core web apps (cookie based auth) and Web APIs (stateless token based auth).
ASP.NET MVC Samples
- RESTful Day #1: Enterprise level application architecture with Web APIs using Entity Framework, Generic Repository pattern and Unit of Work.
- RESTful Day #2: Inversion of control using dependency injection in Web APIs using Unity Container and Bootstrapper.
- RESTful Day #3: Resolve dependency of dependencies using Inversion of Control and dependency injection in Asp.net Web APIs with Unity Container and Managed Extensibility Framework (MEF).
- RESTful Day #4: Custom URL Re-Writing/Routing using Attribute Routes in MVC 4 Web APIs.
- RESTful Day #5: Basic Authentication and Token based custom Authorization in Web APIs using Action Filters.
- RESTful Day #6: Request logging and Exception handing/logging in Web APIs using Action Filters, Exception Filters and NLog.
- RESTful Day #7: Unit Testing and Integration Testing in WebAPI using NUnit and Moq framework (Part1).
- RESTful Day #8: Unit Testing and Integration Testing in WebAPI using NUnit and Moq framework (Part 2).
- RESTful Day #9: Extending OData support in ASP.NET Web APIs.
- RESTful Day #10 : Creating Self Hosted ASP.NET WebAPI with CRUD operations in Visual Studio 2010
MVC6 - Good Samples
https://github.com/ssshekhawat/ASP.NET-Core-MVC-Example
MVC5 - Good Samples
https://github.com/kristianguevara/MyFirstWebsite-ASP.NET-MVC5
Requirements
- Creating your Empty Project
- Creating the Authentication Middleware using Identity
- Installing the Owin packages
- Coding the Middleware
- Connecting the Middleware to the Solution
- Creating the Basic Home Pages
- Adding the Home Controller
- Adding the Home View
- Explaining Views and Master Page
- Adding Authentication Security and Unauthorized Page Placeholder
- Creating the Login Model and Login Form
- Adding the Login logic With Hard-coded Values
- Adding the HttpGet Login Method
- Adding the HttpPost Login Method
- Adding Credential Validations
- Displaying the Error Message and Adding URL Validation
- Displaying Persisted Values and Adding the Logout Logic
- Displaying Your Name
- Creating the Logout Button and Logic
- Creating the Database using LocalDb
- Connecting the Database to the App through Connection Strings
- Creating the Database Tables
- Linking the Database Through Entity Framework
- Creating the Context and Renaming the LoginModel
- Cleaning our AuthController Redirection
- Creating the Registration Page
- Creating the Registration Action and View Page
- Creating Data Encryption and Decryption
- Creating the Query Logic
- Editing the Login Logic
- Creating our List Table
- Creating the UI for the tables
- Creating the List Model and Linking it to the Database
- Adding Input Fields
- Explaining Relationships Between Tables: Another Logged-in User = Different Item List
- Adding Items to our List
- Displaying the Items to the List
- Editing the Items
- Adding the Edit View
- Creating the Edit Logic
- Deleting Items from the List
- Displaying Public Data
- Cleaning the Code
- Debriefing and Summary
Technologies & Tools
- Visual Studio 2013
- EntityFramework version 6
- AspNet.Mvc version 5
- Owin
- Owin (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET): chuẩn giao tiếp mở giữa Web Server và Web Application. Lợi ích của OWIN là:
- Cho phép tạo ra các middleware components có thể thay thế hoặc thêm vào trong ứng dụng mà không ảnh hưởng tới các thành phần khác trong ứng dụng đó.
- Loại bỏ việc host ứng dụng chỉ dựa vào web server, đẩy mạnh hơn việc sử dụng self-host.
KATANA: Framework open source của Microsoft thực thi OWIN. Katana cung cấp Katana's self host server, custom host server như console app, windows service để có thể host các middleware như ASP.NET Web API hay SignalR...
Như vậy có thể thấy giờ đây ngoài IIS, chúng ta còn có thể host ứng dụng trên self-host như Katana server, windows service, console app... Đây là một chiến lược của Microsoft trong việc mở rộng .NET đến các nền tảng như Linux, Mac... Và điều này cũng đem lại nhiều thuận lợi hơn cho lập trình viên chúng ta.
- AspNet.Identity.OWIN: được sử dụng khi bạn thêm hàm login vào hệ thống và gọi OWIN Cookie Authentication middleware để tạo cookie.
- AspNet.Identity.EntityFramework: dùng để ánh xạ dữ liệu và schema ASP.NET vào SQL Server.
- Owin.Host.SystemWeb: cho phép server Owin chạy API trên IIS sử dụng ASP.NET request pipeline.
- AspNet.WebApi.Owin: cho phép bạn lưu trữ ASP.Net Web API trong OWIN Server và cung cấp quyền truy cập các tính năng của OWIN.
- Owin.Security.Oauth: là 1 Middleware, cho phép ứng dụng hỗ trợ đăng nhập bằng Oauth 2.0.
- Owin.Cors: chứa những components cho phép thực hiện Cross-Origin Resource Sharing (CORS) trong OWIN middleware (truy cập các resource bên ngoài).
Cài đặt Nuget Packages
Chúng ta sẽ cài đặt Nuget packages để thiết lập Owin server và cấu hình ASPNET Web API để lưu trữ Owin Server.
- Install-Package Microsoft.AspNet.Identity.Owin
- Install-Package Microsoft.AspNet.Identity.EntityFramework
- Install-Package Microsoft.Owin.Host.SystemWeb
- Install-Package Microsoft.AspNet.WebApi.Owin
- Install-Package Microsoft.Owin.Security.OAuth
- Install-Package Microsoft.Owin.Cors
Tham khảo:
OWIN:
http://johnatten.com/2015/01/04/asp-net-understanding-owin-katana-and-the-middleware-pipeline/
Retrieview json result từ Web API thông qua Console Application
iTextSharp: làm việc với Excel
DocX: làm việc với Word
C# LinqToExcel
http://bitoftech.net/2015/01/21/asp-net-identity-2-with-asp-net-web-api-2-accounts-management/
Researching
Encrypt & Decrypt
https://stackoverflow.com/questions/3253325/cryptographic-exception-input-is-not-a-complete-block
HTML special characters
http://htmlhelp.com/reference/html40/entities/special.html
Users and Roles management
https://code.msdn.microsoft.com/ASPNET-MVC-5-Security-And-44cbdb97
Ví dụ có sử dụng Web API và Bootstrap
http://www.c-sharpcorner.com/UploadFile/8a67c0/repository-pattern-and-generic-repository-pattern/
http://www.c-sharpcorner.com/article/generic-repository-pattern-in-asp-net-core/
https://code.msdn.microsoft.com/Generic-Repository-Pattern-f133bca4
https://code.msdn.microsoft.com/generic-repository-pattern-ddea2262
https://www.codeproject.com/Articles/814768/CRUD-Operations-Using-the-Generic-Repository-Patte
ASP.NET Core MVC Example
This repository holds sample application which developed using ASP.NET Core MVC
First Application
Its name is EmployeeApplication. It is developed using ASP.NET Core 2.0. It tutorial is http://l-knowtech.com/2017/08/15/getting-started-asp-net-core-mvc/
CRUD Operations Using Entity Framework Core
Its solution folder name is FirstCRUDApplication. It's tutorial is http://l-knowtech.com/2017/08/28/first-crud-application-asp-net-core-mvc-using-entity-framework-core/
Repository Pattern In ASP.NET Core MVC And Entity Framework Core
Its solution folder name is RepositoryPattern. It's tutorial is http://l-knowtech.com/2017/09/12/repository-pattern-asp-net-core-mvc-entity-framework-core/
Generic Repository Pattern In ASP.NET Core MVC And Entity Framework Core
Its solution folder name is GenericRepository. It's tutorial is http://l-knowtech.com/2017/09/24/generic-repository-pattern-asp-net-core-mvc-entity-framework-core/
https://github.com/ssshekhawat/ASP.NET-Core-MVC-Example
Clean Architecture with .NET
https://github.com/ardalis/CleanArchitecture
Last updated October 2017 for .NET Core 2.0
https://blogs.msdn.microsoft.com/dotnet/2017/08/09/web-apps-aspnetcore-architecture-guidance/
Updated for ASP.NET Core 2.0 (Nov. 15th 2017)
What’s new
The eBook/Guide has been updated to ASP.NET Core 2.0, .NET Standard Library 2.0 and Entity Framework 2.0 and .NET Core 2.0 in general, while referencing to the new code implemented in the updated sample app for ASP.NET Core 2, as well.
+ ASP.NET Core 2.0
+ ASP.NET Identity 2.0
+ .NET Standard Library 2.0
+ Entity Framework 2.0
+ .NET Core 2.0
+ Two Factor Authentication (2FA)
+ Razor Pages is a new features added in ASP.NET Core 2.0
https://github.com/dotnet-architecture/eShopOnContainers
Easy to get started sample reference microservice and container based application. Cross-platform on Linux and Windows Docker Containers, powered by .NET Core 2.0 and Docker engine. Supports Visual Studio 2017, VS for Mac and CLI based environments with Docker CLI, dotnet CLI, VS Code or any other code editor.
https://github.com/dotnet-architecture/eShopOnWeb
Sample ASP.NET Core 2.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download 130+ page eBook PDF from docs folder.
Layered Architecture in ASP.NET Core Applications
Onion Architecture in ASP.NET Core Applications (Jeffrey Palermo)
Growing Object-Oriented Software
Ports and Adapters Architecture (Hexagonal Architecture)
Generic Repository Pattern in ASP.NET Core
A Visual Studio 2015 project which shows how to perform the create, read, update and delete operations in the ASP.NET Core application using generic repository pattern with Entity Framework Core Code First approach.
https://code.msdn.microsoft.com/Generic-Repository-Pattern-f133bca4
http://www.c-sharpcorner.com/article/generic-repository-pattern-in-asp-net-core/
CRUD with Generic Repository Pattern, Dependency Injection and Unit Of Work
- CRUD Operations Using the Repository Pattern in MVC
- CRUD Operations Using the Generic Repository Pattern and Unit of Work in MVC
- CRUD Operations Using the Generic Repository Pattern and Dependency Injection in MVC
https://code.msdn.microsoft.com/generic-repository-pattern-ddea2262
https://github.com/MuhammadNasirKhanYousafzai/GenericServiceWithRepository
Generic Services will make your life easy as you did not need to implement same functionality again and again. Just write them once and use.
Updated 10/11/2016
Why should not I use the Repository pattern with Entity Framework?
I don't see any reason for the Repository pattern to not work with Entity Framework. Repository pattern is an abstraction layer you put on your data access layer. Your data access layer can be anything from pure ADO.NET stored procedures to Entity Framework or an XML file.
In large systems, where you have data coming from different sources (database/XML/web service), it is good to have an abstraction layer. The Repository pattern works well in this scenario. I do not believe that Entity Framework is enough abstraction to hide what goes on behind the scenes.
I have used the Repository pattern with Entity Framework as my data access layer method and am yet to face a problem.
Another advantage of abstracting the DbContext with a Repository is unit-testability. You can have your IRepository interface to which has 2 implementations, one (the real Repository) which uses DbContext to talk to the database and the second, FakeRepository which can return in-memory objects/mocked data. This makes your IRepository unit-testable, thus other parts of code which uses IRepository.
public interface IRepository
{
IEnumerable<CustomerDto> GetCustomers();
}
public EFRepository : IRepository
{
private YourDbContext db;
private EFRepository()
{
db = new YourDbContext();
}
public IEnumerable<CustomerDto> GetCustomers()
{
return db.Customers.Select(f=>new CustomerDto { Id=f.Id, Name =f.Name}).ToList();
}
}
public MockRepository : IRepository
{
public IEnumerable<CustomerDto> GetCustomers()
{
// to do : return a mock list of Customers
// Or you may even use a mocking framework like Moq
}
}
Now using DI, you get the implementation
public class SomeService
{
IRepository repo;
public SomeService(IRepository repo)
{
this.repo = repo;
}
public void SomeMethod()
{
//use this.repo as needed
}
}