اشتراک‌ها
Visual Studio 2019 RC منتشر شد
Visual Studio 2019 RC منتشر شد
نظرات مطالب
ایجاد ویژگی‌های اعتبارسنجی سفارشی در ASP.NET Core 3.1 به همراه اعتبارسنجی سمت کلاینت آن‌ها
اینم در نظرداشته باشید(FluentValidation  ) . البته من از سمت کلاینتش استفاده نکردم و فکر نکنم داشته باشه. اما شرایط خوبی پوشش میده.
using FluentValidation;

public class CustomerValidator: AbstractValidator<Customer> {
  public CustomerValidator() {
    RuleFor(x => x.Surname).NotEmpty();
    RuleFor(x => x.Forename).NotEmpty().WithMessage("Please specify a first name");
    RuleFor(x => x.Discount).NotEqual(0).When(x => x.HasDiscount);
    RuleFor(x => x.Address).Length(20, 250);
    RuleFor(x => x.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
  }

  private bool BeAValidPostcode(string postcode) {
    // custom postcode validating logic goes here
  }
}

var customer = new Customer();
var validator = new CustomerValidator();
ValidationResult results = validator.Validate(customer);

bool success = results.IsValid;
IList<ValidationFailure> failures = results.Errors;

اشتراک‌ها
بنچمارک gRPC در زبان های مختلف

One repo to finally have a clear, objective gRPC benchmark with code for everyone to verify and improve.


OS: Fedora release 38 (Thirty Eight) x86_64

Host: Z790 UD AX

Kernel: 6.3.6-200.fc38.x86_64

CPU: 13th Gen Intel i9-13900KF (32) @ 5.500GHz

GPU: NVIDIA GeForce RTX 4090

Memory: 64119MiB 


 | java_vertx_grpc             |  201739 |        4.93 ms |        5.57 ms |        6.60 ms |       10.70 ms |   96.63% |     109.0 MiB |
| dotnet_grpc                 |  189382 |        4.97 ms |        5.74 ms |        6.58 ms |       50.39 ms |   99.59% |    239.78 MiB |
| rust_thruster_st            |  189079 |        5.26 ms |        5.70 ms |        5.97 ms |        6.76 ms |   94.39% |     17.51 MiB |
| rust_thruster_mt            |  186403 |        5.34 ms |        2.33 ms |        2.75 ms |      137.25 ms |   93.78% |     19.33 MiB |
| rust_tonic_st               |  181329 |        5.49 ms |        5.96 ms |        6.21 ms |        6.59 ms |   94.35% |     18.31 MiB |
| rust_grpcio                 |  177021 |        5.63 ms |        6.27 ms |        6.48 ms |        7.01 ms |   77.65% |    229.43 MiB |
| cpp_grpc_mt                 |  175054 |        5.69 ms |        6.59 ms |        6.88 ms |        7.52 ms |   76.31% |     20.13 MiB |
| cpp_grpc_st                 |  174633 |        5.70 ms |        6.45 ms |        6.69 ms |        7.30 ms |   76.07% |      9.99 MiB |
| cpp_asio_grpc               |  170664 |        5.84 ms |        6.65 ms |        6.94 ms |        7.55 ms |   77.04% |     20.75 MiB |
| rust_tonic_mt               |  161976 |        6.15 ms |        2.65 ms |        2.92 ms |      175.00 ms |   88.21% |     21.83 MiB |   
بنچمارک gRPC در زبان های مختلف
مطالب
آشنایی با ساختار IIS قسمت دوم
در قسمت قبلی گفتیم که IIS از تعدادی کامپوننت تشکیل شده است و به یکی از آن‌ها به نام Http.sys پرداختیم. در این قسمت قصد داریم به WWW Services بپردازیم.

اجازه بدهید قبل از هر چیزی به دو مفهوم اصلی در IIS بپردزیم :

1. Worker Process

2. Application Pool

پروسه‌های کارگر  w3wp.exe  وظیفه‌ی اجرای برنامه‌های asp.net را در IIS ، به عهده دارند. این پروسه‌ها مسئولیت پردازش تمامی درخواست و پاسخ‌ها از/به کلاینت را دارند. هر کاری که باید در asp.net انجام بشود، توسط این‌ها صورت می‌گیرد. به بیان ساده‌تر این پروسه‌ها قلب برنامه‌های ASP.Net بر روی IIS هستند .

Application Pool:این پول‌ها در واقع ظرفی یا در برگیرنده ای برای پروسه‌های کارگر به حساب می‌آیند. این پول‌ها پروسه‌های کارگر را از هم جدا و دسته بندی می‌کنند تا قابلیت اعتماد، امنیت و در دسترس بودن بدهند. موقعی که یک پروسه یا حتی یک پول دچار مشکل می‌شود، این اطمینان داده می‌شود که تاثیری بر دیگر پول‌ها یا پروسه‌های کارگر، ندارد. یعنی موقعی که یک web application  دچار مشکل شود، هیچ تاثیری بر اجرای  web application‌های دیگر ندارد. به یک application pool با چند پروسه کارگر  web garden  میگویند. 


World Wide WebPublishing Services
یکی از قدیمی‌ترین امکانات موجود در IIS هست که از نسخه 7 به بعد، کار خود را با یک سروریس جدید به اسم Windows Process Activation Service یا به اختصار WAS که به صورت local system بر روی پروسه Svchost.exe با یک کد باینری یکسان اجرا می‌شود، شریک شده است. ممکن است در بعضی جاها WWW Service به صورت W3SVC هم نوشته شود.

اصلا این WWW Service چه کاری انجام می‌دهد و به چه دردی می‌خورد؟
این سرویس در سه بخش مهم  IIS 6 به فعالیت می‌پردازد:
  • HTTP administration and configuration
  •  Performance monitoring
  • Process management

HTTP Administration and Configuration 

سرویس WWW وظیفه خواندن اطلاعات پیکربندی IIS از متابیس را بر عهده دارد و از این اطلاعات خوانده شده برای پیکربندی و به روز کردن Http.sys استفاده می‌کند. به غیر از این کار، وظیفه آغاز و توقف و نظارت یا مانیتورینگ و همچنین مدیریت کامل پروسه‌های کارگر در زمینه http request را هم عهده دار است.

Performance Monitoring 
سرویس WWW بر کارآیی وب سایت‌ها و کش IIS نظارت می‌کند و البته یک شمارنده کارآیی performance counter هم ایجاد می‌کند. کار شمارنده کارآیی این است که اطلاعات یک سرویس یا سیستم عامل یا یک برنامه کاربردی را جمع آوری می‌کند تا به ما بگوید که این بخش‌ها به چه میزانی بهینه کار خود را انجام می‌دهند و به ما کمک می‌کنند که سیستم را به بهترین کارآیی برسانیم. سیستم عامل، شبکه و درایورها، داده‌های شمارشی را تهیه و در قالب یک سیستم نظارتی گرافیکی به کارشناس سیستم یا شبکه نشان می‌دهند. برنامه نویس‌ها هم از این طریق می‌توانند برنامه‌های خود را بنویسند که در اینجا لیستی از شمارنده‌ها در دانت نت را می‌توانید ببینید و بیشتر آن‌ها از طریق فضای نام system.diagnostic در دسترس هستند.

Process Management 
سرویس www مدیریت application pool و پروسه‌های کارگر را هم به عهده دارد. این مدیریت شامل شروع و توقف و بازیابی پروسه‌های کارگر می‌شود. به علاوه اینکه این سرویس کار نظارت بر صحت انجام عملیات پروسه‌های کارگر را هم جز وظایف خود می‌داند. وقتی که چندین بار کار پروسه‌های کارگر در یک دوره زمانی که در فایل پیکربندی مشخص شده با مشکل مواجه شود، از شروع یک پروسه کارگر دیگر جلوگیری می‌کند.

در نسخه‌های جدیدتر IIS چکاری بر عهده WWW Service است؟
در IIS7 به بعد، دیگر مدیریت پروسه‌های کارگر را به عهده ندارد؛ ولی به جای آن سمتی جدید را به اسم listener adapter، دریافت کرده است که یک listener adapter برای http listener یعنی Http.sys است. اصلی‌ترین وظیفه فعلی را که انجام می‌دهد پیکربندی Http.sys می‌باشد. موقعی که اطلاعات پیکربندی به روز می‌شوند باید این تغییرات بر روی Http.sys اعمال شوند. دومین وظیفه آن این است موقعی که درخواست جدیدی وارد صف درخواست‌ها می‌شود این مورد را به اطلاع WAS برساند.
WAS در قسمت سوم این مقاله توضیح داده خواهد شد.
نظرات مطالب
آزمایش Web APIs توسط Postman - قسمت چهارم - نوشتن آزمون‌ها و اسکریپت‌ها
یک نکته‌ی تکمیلی: نمونه‌هایی از آزمایش‌های Postman


بررسی status code دریافتی از سرور
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("Status code is 200", function () {
    pm.expect(pm.response.code).to.equal(200);
});

pm.test("Request is successful", function () {
    pm.response.to.be.succes;
}); // Status code is in the 2XX range

pm.test("Request results in a client error", function () {
    pm.response.to.be.clientError;
}); // Status code is in the 4XX range

pm.test("Request results in a Not Found error", function () {
    pm.response.to.be.notFound;
}); // 404

pm.test("Status code is 200 or 204", function () {
    pm.expect([200, 204]).to.include(pm.response.code);
});

بررسی هدرهای دریافتی از سرور
pm.test("Response has Content-Type header", function () {
    pm.response.to.have.header("Content-Type");
});

pm.test("Response has Content-Type header with application/json; charset = utf - 8 as value", function () {
    pm.response.to.have.header(
        'Content-Type',
        'application/json; charset=utf-8');
});

بررسی بدنه‌ی درخواست
pm.test("Response has a non-empty body", function () {
    pm.expect(pm.response.text()).not.empty;
});

pm.test("Response has a non-empty body", function () {
    pm.expect(pm.response.json()).not.empty;
});

pm.test("Response has a non-empty body", function () {
    pm.response.to.have.body();
});

pm.test("Response has a non-empty body", function () {
    pm.response.to.have.jsonBody();
});

بررسی خواص اشیاء دریافتی از سرور
var updatedAuthor = pm.response.json();
pm.test("Author properties have been updated", function () {
    pm.expect(updatedAuthor.firstName).to.equal("Vahid");
    pm.expect(updatedAuthor.lastName).to.equal("N");
});
اشتراک‌ها
نیازمندیهای یک پروژه ASP.NET Core Web API, Part 1 - Serilog

Why Serilog? It is easy to set up, has a clean API, and is portable between recent .NET platforms. The big difference between Serilog and the other frameworks is that it is designed to do structured logging out of the box. Another thing I really like about Serilog is that it can be configured via the appsetting.json file alongside configuring through code. Changing logging configuration without touching the codebase is really helpful, especially in the production environment. 

نیازمندیهای یک پروژه ASP.NET Core Web API, Part 1 - Serilog
اشتراک‌ها
AutoMapper 8.1.0 منتشر شد

AutoMapper 8.1 adds a major new feature - attribute-based maps. Attribute maps let you easily declare maps on destination types when you have straightforward scenarios. Instead of: 


public class OrderProfile {  
    public OrderProfile() {
        CreateMap<Order, OrderIndexModel>();
        CreateMap<Order, OrderEditModel>();
        CreateMap<Order, OrderCreateModel>();
    }
}


You can declare your type maps directly on the destination types themselves with AutoMapAttribute: 


[AutoMap(typeof(Order))]
public class OrderIndexModel {  
    // members
}

[AutoMap(typeof(Order))]
public class OrderEditModel {  
    // members
}

[AutoMap(typeof(Order))]
public class OrderCreateModel {  
    // members
}


AutoMapper 8.1.0 منتشر شد
اشتراک‌ها
پیاده سازی AutoPostBack در ASP.NET Core

Those of you who worked with ASP.NET web forms will recollect that certain server controls such as DropDownList have a property called AutoPostBack. This property when set to true automatically submits the form to the server whenever the selection changes and raises some server side event. In modern web development people prefer to use Ajax over AutoPostBack but at times AutoPostBack is what you might need. To that end this article shows how AutoPostBack can be implemented in ASP.NET Core applications. 

پیاده سازی AutoPostBack در ASP.NET Core
اشتراک‌ها
دریافت آخرین به روز رسانی تجمعی SQL Server 2016 SP1
  • This update contains fixes for issues that were fixed after the release of SQL Server 2016 SP1.
  • The latest 2016 SP1 update is CU2 - 4013106
  • You may have been directed here from a previous SP1 Cumulative Update Knowledge Base (KB) article (See SQL Server 2016 SP1 build versions)
  • This Cumulative Update includes all fixes from all previous SP1 Cumulative Updates, therefore it can be installed to resolve issues fixed in any previous SP1 CU 
دریافت آخرین به روز رسانی تجمعی SQL Server 2016 SP1
اشتراک‌ها
کتاب رایگان NancyFX Succinctly

In NancyFX Succinctly, you'll learn what NancyFX is all about, where it came from, and what it can do for you as a .NET developer. Author Peter Shaw will explain why NancyFX is more than just another web framework, and teach you some of the many tricks that make it as easy as possible for you to create stunning web-enabled applications on the .NET platform.  

کتاب رایگان NancyFX Succinctly