DNTCommon.Web.Core provides common scenarios' solutions for ASP.NET Core applications.
DNTCommon.Web.Core
provides common scenarios' solutions for ASP.NET Core applications.
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.
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>
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();
}
ActionResults
Caching
no-cache
, must-revalidate
, no-store
headers for the current Response
.DependencyInjection
Drawing
Http
MailKit
library. It's able to use razor based email templates.ModelBinders
services.AddMvc(options => options.UsePersianDateModelBinder())
or just apply it to an specific
view-model [ModelBinder(BinderType = typeof(PersianDateModelBinder))]
.services.AddMvc(options => options.UseYeKeModelBinder())
or just apply it to an specific
view-model [ModelBinder(BinderType = typeof(YeKeModelBinder))]
.services.AddControllersWithViews(options => options.Filters.Add(typeof(ApplyCorrectYeKeFilterAttribute)))
.Mvc
Blazor
Schedulers
HostingEnvironment.QueueBackgroundWorkItem
method.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
X-Requested-With
header has XMLHttpRequest
value.Microsoft.AspNetCore.DataProtection.IDataProtector
. It's only useful for
short-term encryption scenarios such as creating encrypted HTTP cookies.Directory Traversal
& File Inclusion
attacks.app.UseAntiDos()
and services.Configure<AntiDosConfig>
to Startup.cs
file. Then complete the AntiDosConfig
section of
the appsettings.json
file.services.Configure<AntiXssConfig>
to Startup.cs
file. Then complete the AntiXssConfig
section of
the appsettings.json
file.