ASP.NET Core News is the only weekly newsletter dedicated to ASP.NET Core. Whether you build Razor Pages, MVC applications, Web APIs, SignalR awesomeness, or anything else available on the ASP.NET Core platform, we've got you covered. Every Friday you will receive a weekly digest of the most interesting posts and articles from the last seven days.
Paper Cut یک ایمیل سرور دسکتاپ
ASP.NET MVC #18
- سپس دو کلاس Role و User را باید تعریف کنید. این دو رابطه many-to-many با هم دارند؛ یعنی هر کدام با یک ICollection به دیگری ارتباط پیدا میکنند. سپس این دو کلاس را در کلاس Context برنامه مطابق معمول توسط DbSetها در معرض دید EF قرار میدهید. مابقی آن کارکردن معمولی با این دو جدول اضافه شده به برنامه است:
public class EfRolesService : IRolesService { readonly IUnitOfWork _uow; readonly IDbSet<Role> _roles; public EfRolesService(IUnitOfWork uow) { _uow = uow; _roles = _uow.Set<Role>(); } public IList<Role> FindUserRoles(int userId) { var query = from role in _roles from user in role.Users where user.Id == userId select role; return query.OrderBy(x => x.Name).ToList(); } public string[] GetRolesForUser(int userId) { var roles = FindUserRoles(userId); if (roles == null || !roles.Any()) { return new string[] { }; } return roles.Select(x => x.Name).ToArray(); } public bool IsUserInRole(int userId, string roleName) { var query = from role in _roles where role.Name == roleName from user in role.Users where user.Id == userId select role; var userRole = query.FirstOrDefault(); return userRole != null; } }
public class CustomRoleProvider : RoleProvider { public override bool IsUserInRole(string username, string roleName) { // Since the role provider, in this case the CustomRoleProvider is instantiated by // the ASP.NET framework the best solution is to use the service locator pattern. // The service locator pattern is normally considered to be an anti-pattern but // sometimes you have to be pragmatic and accept the limitation on the framework // that is being used (in this case the ASP.NET framework). var rolesService = ObjectFactory.GetInstance<IRolesService>(); return rolesService.IsUserInRole(username.ToInt(), roleName); } public override string[] GetRolesForUser(string username) { var rolesService = ObjectFactory.GetInstance<IRolesService>(); return rolesService.GetRolesForUser(username.ToInt()); } // مابقی نیازی نیست پیاده سازی شوند
کتابخانه slick
System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found. To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'. For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
Secure Connection Failed An error occurred during a connection to localhost:5001. Certificate key usage inadequate for attempted operation. Error code: SEC_ERROR_INADEQUATE_KEY_USAGE
dotnet dev-certs https --clean dotnet dev-certs https --trust
سری بررسی مقدمات Blazor
Blazor Fundamentals Tutorial
Blazor server-side vs client-side (WebAssembly) | What should you choose?
What are Razor Components? | Blazor Tutorial 1
Dependency Injection | Blazor Tutorial 2
What are Blazor Layouts? | Blazor Tutorial 3
Routing and Navigation | Blazor Tutorial 4
JS Interop: Calling JavaScript from C# | Blazor Tutorial 5
JS Interop: Calling C# methods from JavaScript | Blazor Tutorial 6
Creating Forms with Validation | Blazor Tutorial 7
How to add Authentication in Server-side Blazor | Blazor Tutorial 8
Authorization in Server-Side Blazor | Blazor Tutorial 9
How to use HTML5 Web Storage in Blazor | Blazor Tutorial 10
Managing Blazor state using Redux | Blazor Tutorial 11
Creating a desktop application using Blazor and Electron | Blazor Tutorial 12
Deploying Server-Side Blazor in Azure with SignalR service | Blazor Tutorial 13
Building cross platform mobile apps with Blazor (Experimental)
تزریق وابستگی ها در Asp.net MVC 5
If you are using StructreMap to resolve the dependencies in the ASP.NET MVC 5 application then Steve Smith’s blog postResolving Dependencies in ASP.NET MVC 5 with StructureMap can be a great help for you