فرمهای پویا با Facebook React
Web-based applications run smoother if instead of using the traditional form method, they use JavaScript to post data to the server and to update the user interface after posting data: It also makes it easier to keep POST and GET actions separated. SignalR makes it even slicker; it can even update multiple pages at the same time. Is it time to use JavaScript to post data rather than posting via the browser the traditional way?
Professional REST API design with ASP.NET Core and WebAPI
This project is an example of lightweight and extensible infrastructure for building RESTful Web API with ASP.NET Core.
This example contains a number of tricks and techniques which I've learned while building APIs in ASP.NET Core.
Techniques and Features
- JWT Authentication
- Secure JWT using Encryption (JWE)
- Logging to File, Console and Database using Elmah & NLog
- Logging to sentry.io (Log Management System)
- Exception Handling using Custom Middleware
- Automatic Validation
- Standard API Resulting
- Dependency Injection using Autofac
- Map resources using AutoMapper
- Async/Await Best Practices
- Versioning Management
- Using Swagger (Swashbuckle)
- Auto Document Generator for Swagger
- Integrate Swagger and Versioning
- Integrate Swagger and JWT/OAuth Authentication
- Best Practices for Performance and Security
6.Visual Studio 2017 15.9 منتشر شد
These are the customer-reported issues addressed in 15.9.6:
- Installation failures of the Unity Editor component in China.
- Starting a new nanoFramework project from a template.
- Deployment errors after VS2017 update.
- Android Deploy failed - Error ADB0010.
- Error in German translation: info bar "session closed unexpectedly".
- Visual Studio 2017 create offline layout problem: Failed to load from stream for non-ENU layouts.
- Extension auto-update can leave extension disabled.
شروع کار با Unit Testing - قسمت اول
<services> <service name="MyNewsWCFLibrary.MyNewsService"> <host> <baseAddresses> <add baseAddress="http://localhost:8080/MyNewsWCFLibrary/MyNewsService/" /> </baseAddresses> </host> <!-- Service Endpoints --> <!-- Unless fully qualified, address is relative to base address supplied above --> <endpoint address="" binding="basicHttpBinding" contract="MyNewsWCFLibrary.IMyNewsService"> <!-- Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. If removed, WCF will infer an appropriate identity automatically. --> <identity> <dns value="localhost" /> </identity> </endpoint> <!-- Metadata Endpoints --> <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services>
در صورت مشاهده پیام خطا، ویژوال استودیو را ببندید و اینبار به صورت Run as administrator باز کنید.
برای نمونه روی متد AddCategory کلیک کنید. در پنجره نشان داده شده همانند شکل در برابر فیلد CatName مقداری وارد کنید و روی دکمه Invoke کلیک کنید. متد مورد نظر اجرا شده و مقداری که وارد کرده ایم در پایگاه دادهها ذخیره میشود. مقداری که در قسمت پایین دیده میشود خروجی متد است که در اینجا شناسه رکورد درجشده است.
بار دیگر برای مشاهده رکورد درجشده روی متد GetAllCategory کلیک کنید. به علت اینکه این متد ورودی ندارد در قسمت بالا چیزی نشان داده نمیشود. روی دکمه Invoke کلیک کنید. با پیغام خطای زیر روبهرو خواهید شد:
افزودن ویژگی Virtual به tblNews و tblCategory در بخش دوم خواندید؛ باعث میشود که Entity Framework در هنگام اجرا کلاسهایی با عنوان "پروکسیهای پویا" به کلاسهای Address و Customer بیفزاید و بنابراین قابلیت Lazy Loading برای این کلاسها در زمان اجرای برنامه فراهم میگردد.
ولی با افزودن پروکسیهای پویا به کلاسهای ما، این کلاسها قابلیت انتقال خود از طریق سرویسهای WCF را از دست میدهند زیرا پروکسیهای پویا به طور پیشگزیده قابلیت سریالایز و دیسریالایز شدن را ندارند!
خوشبختانه میتوانیم این ویژگی را در کلاس DBContext غیرفعال کنیم. برای این منظور قالب سازندهی آن یا MyNewsModel.Context.tt را از Solution Explorer باز کنید و کد زیر را در آن پیدا کنید:
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext { public <#=code.Escape(container)#>() : base("name=<#=container.Name#>") {
سپس در ادامهی آن کدغیرفعالکردن پروکسی پویا را به این شکل بنویسید:
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext { public <#=code.Escape(container)#>() : base("name=<#=container.Name#>") { Configuration.ProxyCreationEnabled = false;
اکنون اگر فایل را ذخیره کنیم سپس فایل MyNewsModel.Context.cs را از Solution Explorer باز کنید؛ خواهید دید که این خط کد در جای خود قرارگرفته است.
بار دیگر پروژه را اجرا کنید روی متد GetAllCategory کلیک کنید. این بار اگر دکمه Invoke را بفشارید با همانند شکل زیر را خواهید دید:
در بخش ششم پیرامون ارتباط جدولهای tblNews و tblCategory و نمایش محتویات وابسته جدول خبر به دسته و تنظیمات آن در t4 و کلاس Service
در بخش هفتم پیرامون میزبانی WCFLibrary در یک Web Application
و در بخش هشتم پیرامون ایجاد یک برنامهی ویندوزی جهت استفاده از سرویسهای WCF خواهم نوشت.