اشتراک‌ها
آکادمی برای روزلین
The Roslyn Academy is an online community dedicated to writing code and building applications based on the Microsoft .NET Compiler Platform.We feature passionate developers and expert people about the Roslyn APIs. 
آکادمی برای روزلین
اشتراک‌ها
روش های مدرن برای ثبت خطا در سی شارپ

Logging is a big part of software development for many years now. One can argue that a logging mechanism is a must-have part of any application or library. I would agree with that statement. Logging has a crucial part to play in a scenario where you can’t use interactive debugging (that is, attaching a debugger like Visual Studio). It allows us to investigate errors after the problem already happened. In some cases, like Production Debugging, logs might be the only information you have. 

روش های مدرن برای ثبت خطا در سی شارپ
اشتراک‌ها
کتابخانه amplitudejs
A JavaScript library that allows you to control the design of your media controls in your webpage -- not the browser. No dependencies (jQuery not required) Demo
کتابخانه amplitudejs
اشتراک‌ها
اجرای C# در مرورگر بوسیله Web Assembly

C# is usually thought of as a backend, server-side language. But with the Blazor-Web Assembly combo, developers can use it for client-side as well. 

اجرای C# در مرورگر بوسیله Web Assembly
اشتراک‌ها
اعتبارسنجی کاربران بدون هاردکد کردن نقشها

You already know how role-based authorization works in ASP.NET Core.

[Authorize(Roles = "Administrator")]
public class AdministrationController : Controller
{
}

But what if you don't want hardcode roles on the Authorize attribute or create roles later and specify in which controller and action it has access without touching source code?

DynamicAuthorization helps you authorize users without hardcoding role(s) on the Authorize attribute with minimum effort. DynamicAuthorization is built at the top of ASP.NET Core Identity and use identity mechanism for managing roles and authorizing users. 

اعتبارسنجی کاربران بدون هاردکد کردن نقشها
نظرات مطالب
افزودن و اعتبارسنجی خودکار Anti-Forgery Tokens در برنامه‌های Angular مبتنی بر ASP.NET Core
زمانیکه در برنامه این موارد رو اعمال میکنم  درخواست هایی که دارای هدر Authorization  باشند با خطای زیر مواجه میشوند: 

Antiforgery token validation failed. The provided antiforgery token was meant for a different claims-based user than the current user.
اما برای درخواست‌های فاقد هدر Authorization این مشکل وجود ندارد.
نظرات مطالب
اعتبارسنجی مبتنی بر JWT در ASP.NET Core 2.0 بدون استفاده از سیستم Identity
آیا امکان انتقال تنظیمات jwt به لایه دیگر وجود دارد؟
منظورم از تنظیمات:
            services.AddAuthorization(options =>
                    {
                        options.AddPolicy(CustomRoles.Admin, policy => policy.RequireRole(CustomRoles.Admin));
                        options.AddPolicy(CustomRoles.User, policy => policy.RequireRole(CustomRoles.User));
                        options.AddPolicy(CustomRoles.Editor, policy => policy.RequireRole(CustomRoles.Editor));
                    });

            // Needed for jwt auth.
            services
                .AddAuthentication(options =>
                {
                    options.DefaultChallengeScheme = siteSettings.JwtBearerDefaults.AuthenticationScheme;
                    options.DefaultSignInScheme = siteSettings.JwtBearerDefaults.AuthenticationScheme;
                    options.DefaultAuthenticateScheme = siteSettings.JwtBearerDefaults.AuthenticationScheme;
                })
                .AddJwtBearer(cfg =>
                {
                    cfg.RequireHttpsMetadata = false;
                    cfg.SaveToken = true;
                    cfg.TokenValidationParameters = new TokenValidationParameters
                    {
                        ValidIssuer = Configuration["BearerTokens:Issuer"], // site that makes the token
                        ValidateIssuer = false, // TODO: change this to avoid forwarding attacks
                        ValidAudience = Configuration["BearerTokens:Audience"], // site that consumes the token
                        ValidateAudience = false, // TODO: change this to avoid forwarding attacks
                        IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["BearerTokens:Key"])),
                        ValidateIssuerSigningKey = true, // verify signature to avoid tampering
                        ValidateLifetime = true, // validate the expiration
                        ClockSkew = TimeSpan.Zero // tolerance for the expiration date
                    };
من نتونستم این سرویس هارو در لایه Ioc خودم ایجاد کنم. مشکلم هم بابت عدم وجود AddAuthentication   بود. هر چند من پکیج‌های زیر را اضافه کردم اما نتوانستم تمام سرویس‌ها رو تکمیل کنم
Microsoft.AspNetCore.Authorization  و Microsoft.AspNetCore.Authorization.Policy من از نسخه 3.1.201 استفاده میکنم
اشتراک‌ها
NET 7 Preview 4. منتشر شد

The fourth preview of .NET 7 includes enhancements to observability in the .NET implementation of OpenTelemetry, the addition of properties to track microseconds and nanoseconds in date and time structures, new metrics for caching extensions, performance-boosting “on stack replacement,” APIs to work with .tar archives, and additional features as part of an ongoing effort to improve the performance of and add features to regular expressions in .NET 7.  

NET 7 Preview 4. منتشر شد