DNTCommon.Web.Core

2025-12-07 0 697

DNTCommon.Web.Core

DNTCommon.Web.Core provides common scenarios\’ solutions for ASP.NET Core applications.

Install via NuGet

To install DNTCommon.Web.Core, run the following command in the Package Manager Console:

PM> Install-Package DNTCommon.Web.Core

You can also view the package page on NuGet.

Linux (and containers) support

The SkiaSharp library needs extra dependencies to work on Linux and containers. Please install the following NuGet
packages:

PM> Install-Package SkiaSharp.NativeAssets.Linux.NoDependencies
PM> Install-Package HarfBuzzSharp.NativeAssets.Linux

You also need to modify your .csproj file to include some MSBuild directives that ensure the required files are in a
good place. These extra steps are normally not required but seems to be some issues on how .NET loads them.

<Target Name=\"CopyFilesAfterPublish\" AfterTargets=\"AfterPublish\">
    <Copy SourceFiles=\"$(TargetDir)runtimes/linux-x64/native/libSkiaSharp.so\" DestinationFolder=\"$([System.IO.Path]::GetFullPath(\'$(PublishDir)\'))/bin/\" />
    <Copy SourceFiles=\"$(TargetDir)runtimes/linux-x64/native/libHarfBuzzSharp.so\" DestinationFolder=\"$([System.IO.Path]::GetFullPath(\'$(PublishDir)\'))/bin/\" />    
</Target>

Usage

After installing the DNTCommon.Web.Core package, to register its default providers, call services.AddDNTCommonWeb();
method in
your Startup class.

using DNTCommon.Web.Core;

namespace MyWebApp
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDNTCommonWeb();
        }

Features

  • ActionResults

    • FeedResult
      is an ASP.NET Core RSS feed renderer.
    • OpenSearchResult
      is an ASP.NET Core OpenSearch description format provider.
    • SitemapResult
      is an ASP.NET Core Sitemap renderer.
  • Caching

    • ICacheService
      encapsulates IMemoryCache functionalities.
    • [NoBrowserCache]
      action filter sets no-cache, must-revalidate, no-store headers for the current Response.
  • DependencyInjection

    • IServiceProviderExtensions
      creates an IServiceScope which contains an IServiceProvider used to resolve dependencies from a newly created
      scope and then runs an associated callback.
  • Drawing

    • TextToImageExtensions
      and TextToImageResult
      draw a text on a bitmap and then return it as a png byte array.
  • Http

    • ICommonHttpClientFactory
      service, reuses a single HttpClient instance across a multi-threaded application.
    • DomainHelperExtensions
      provides useful extension methods to extract domain info of the URL\’s.
    • IDownloaderService
      encapsulates HttpClient\’s best practices of downloading large files.
    • IHtmlHelperService
      provides helper methods to work with HTML contents such as extracting links and titles or changing relative Urls
      to absolute Urls.
    • IHttpRequestInfoService
      provides useful methods to work with current HttpContext.Request.
    • IRedirectUrlFinderService
      finds the actual hidden URL after multiple redirects.
    • IUrlNormalizationService
      transforms a URL into a normalized URL so it is possible to determine if two syntactically different URLs may be
      equivalent.
    • IHtmlReaderService
      reads the HTML document\’s nodes recursively.
    • IUAParserService is the updated version of the UAParser library with the latest regexes.yaml file.
  • Mail

    • IWebMailService
      simplifies sending an email using the MailKit library. It\’s able to use razor based email templates.
  • ModelBinders

    • PersianDateModelBinderProvider
      parses an incoming Persian date and then binds it to a DateTime property automatically. To use it globally (
      assuming your app only sends Persian dates to the server), Add it to
      MvcOptions: services.AddMvc(options => options.UsePersianDateModelBinder()) or just apply it to an specific
      view-model [ModelBinder(BinderType = typeof(PersianDateModelBinder))].
    • YeKeModelBinderProvider
      parses an incoming text and then corrects its Ye & Ke characters automatically. To use it globally, Add it to
      MvcOptions: services.AddMvc(options => options.UseYeKeModelBinder()) or just apply it to an specific
      view-model [ModelBinder(BinderType = typeof(YeKeModelBinder))].
    • ApplyCorrectYeKeFilterAttribute
      parses an incoming text and then corrects its Ye & Ke characters automatically. To use it globally, Add it to
      MvcOptions: services.AddControllersWithViews(options => options.Filters.Add(typeof(ApplyCorrectYeKeFilterAttribute))).
  • Mvc

    • ControllerExtensions
      provides useful extension methods to work with MVC Controllers.
    • IMvcActionsDiscoveryService
      provides a way to list all of the controllers and action methods of an MVC application.
    • IViewRendererService
      helps rendering a .cshtml file as an string. It\’s useful for creating razor based email templates.
    • UploadFileService
      saves the posted IFormFile to the specified directory asynchronously.
  • Blazor

    • IBlazorStaticRendererService
      helps rendering a razor component as an string. It\’s useful for creating razor based email templates.
    • IBlazorRenderingContext
      helps detecting the current rendering mode of a razor component.
  • Schedulers

    • BackgroundQueueController
      A .NET Core replacement for the old HostingEnvironment.QueueBackgroundWorkItem method.
    • ScheduledTasksController
      DNTScheduler.Core is a lightweight ASP.NET Core\’s background tasks runner and scheduler. To define a new
      task, create a new class
      that implements the IScheduledTask interface. To register this new task, call services.AddDNTScheduler();
      method in
      your Startup class. AddDNTScheduler
      method, adds this new task to the list of the defined tasks. Also its first parameter defines the custom logic of
      the running intervals of this task. It\’s a callback method that will be called every second and provides the
      utcNow value. If it returns true, the job will be executed.If you have multiple jobs at the same time, the order
      parameter\’s value indicates the order of their execution.
  • Security

    • [AjaxOnly]
      action filter determines whether the HttpRequest\’s X-Requested-With header has XMLHttpRequest value.
    • IProtectionProviderService
      is an encryption provider based on Microsoft.AspNetCore.DataProtection.IDataProtector. It\’s only useful for
      short-term encryption scenarios such as creating encrypted HTTP cookies.
    • IFileNameSanitizerService
      determines whether the requested file is safe to download to avoid Directory Traversal & File Inclusion
      attacks.
    • UploadFileExtensions
      attribute determines only selected file extensions are
      safe to be uploaded.
    • AllowUploadSafeFiles
      attribute disallows uploading dangerous files such as .aspx, web.config and .asp files.
    • AntiDosMiddleware
      is a rate limiter and throttling middleware for ASP.NET Core apps. To use it first add app.UseAntiDos()
      and services.Configure<AntiDosConfig>
      to Startup.cs
      file. Then complete the AntiDosConfig section of
      the appsettings.json
      file.
    • IAntiXssService
      provides a cleaning service for unsafe HTML fragments that can lead to XSS attacks based on a whitelist of allowed
      tags and attributes. To use it add services.Configure<AntiXssConfig>
      to Startup.cs
      file. Then complete the AntiXssConfig section of
      the appsettings.json
      file.
    • IPasswordHasherService provides a custom Pbkdf2
      hashing and validating service.

下载源码

通过命令行克隆项目:

git clone https://github.com/VahidN/DNTCommon.Web.Core.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 开发教程 DNTCommon.Web.Core https://www.zuozi.net/31539.html

go extend
上一篇: go extend
wagi
下一篇: wagi
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务