اشتراکها
اشتراکها
خلاصه برنامههای آتی NET Core.
اشتراکها
datagrip یک IDE جدید برای SQL
اشتراکها
درباره ConnectJs
اشتراکها
ویژوال استدیو 14 CTP
اشتراکها
افزونه Funnel
Funnel به معنی قیف
برای مدیریت لود کردن پروژهها در یک Solution بزرگ
با این افزونه میتوانید تعداد کمی پروژه که الان میخواهید بر روی آن کار کنید را فقط لود کنید ! مزیت در پروژه هایی با 20 تا پروژه کاملا مشهود میباشد
و موجب بالا رفتن سرعت لود و کار VSبا ویژوال استودیو خواهد شد مخصوصا اگر معتاد RSharper هم باشید
برای مدیریت لود کردن پروژهها در یک Solution بزرگ
با این افزونه میتوانید تعداد کمی پروژه که الان میخواهید بر روی آن کار کنید را فقط لود کنید ! مزیت در پروژه هایی با 20 تا پروژه کاملا مشهود میباشد
و موجب بالا رفتن سرعت لود و کار VSبا ویژوال استودیو خواهد شد مخصوصا اگر معتاد RSharper هم باشید
نظرات مطالب
افزودن و اعتبارسنجی خودکار Anti-Forgery Tokens در برنامههای Angular مبتنی بر ASP.NET Core
یک چنین پیاده سازی خواهد داشت:
using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Helpers; using System.Web.Http.Controllers; using System.Web.Http.Filters; using System.Web.Mvc; using ActionFilterAttribute = System.Web.Http.Filters.ActionFilterAttribute; namespace NgxAntiforgeryWebApi.Providers { public class XsrfCookieGeneratorAttribute : ActionFilterAttribute { public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { var xsrfTokenCookie = new HttpCookie("XSRF-TOKEN") { Value = ComputeXsrfTokenValue(), HttpOnly = false // Now JavaScript is able to read the cookie }; HttpContext.Current.Response.AppendCookie(xsrfTokenCookie); } private string ComputeXsrfTokenValue() { string cookieToken, formToken; AntiForgery.GetTokens(null, out cookieToken, out formToken); return $"{cookieToken}:{formToken}"; } } public class XsrfTokensValidationAttribute : ActionFilterAttribute { public override void OnActionExecuting(HttpActionContext actionContext) { IEnumerable<string> headerValues; if (!actionContext.Request.Headers.TryGetValues("X-XSRF-TOKEN", out headerValues)) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = "X-XSRF-TOKEN header is missing." }; return; } if (headerValues == null) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = "X-XSRF-TOKEN header value is empty." }; return; } var xsrfTokensValue = headerValues.FirstOrDefault(); if (string.IsNullOrEmpty(xsrfTokensValue) || !xsrfTokensValue.Contains(":")) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = "X-XSRF-TOKEN header value is null." }; return; } var values = xsrfTokensValue.Split(':'); if (values.Length != 2) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = "X-XSRF-TOKEN header value is malformed." }; return; } var cookieToken = values[0]; var formToken = values[1]; try { AntiForgery.Validate(cookieToken, formToken); } catch (HttpAntiForgeryException ex) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = ex.Message }; } } } }
مشکلی اصلی که در اینجا وجود دارد این است که چرا کامپایلر فعلی Angular (یعنی تا نگارش 7 آن)، قادر نیست وابستگیهایی را که در برنامه ارجاعی به آنها وجود ندارند، در بسته یا بستههای کامپایل شدهی نهایی لحاظ نکند؟ این مشکل قرار است در نگارش 8 آن با ارائهی یک کامپایلر جدید به نام Ivy که مدت زیادی است مشغول به کار بر روی آن هستند، برطرف شود:
The cool thing about Ivy versus the older compilers, however, is that
it’s “ tree-shaking friendly ,” which basically means that it
automatically removes unused bits of code (including unused Angular
features!), shrinking your bundles.