aspnetcore/security/gdpr/includes/gdpr2.md
:::moniker range="= aspnetcore-2.2"
true, non-essential cookies aren't sent to the browser.The sample app allows you to test most of the GDPR extension points and APIs added to the ASP.NET Core 2.1 templates. See the ReadMe file for testing instructions.
View or download sample code (how to download)
Razor Pages and MVC projects created with the project templates include the following GDPR support:
Startup class.Pages/Privacy.cshtml page or Views/Home/Privacy.cshtml view provides a page to detail your site's privacy policy. The _CookieConsentPartial.cshtml file generates a link to the Privacy page.xref:Microsoft.AspNetCore.Builder.CookiePolicyOptions are initialized in Startup.ConfigureServices:
[!code-csharpMain]
xref:Microsoft.AspNetCore.Builder.CookiePolicyAppBuilderExtensions.UseCookiePolicy%2A is called in Startup.Configure:
The _CookieConsentPartial.cshtml partial view:
This partial:
<p> element to summarize your privacy and cookie use policy.If consent to store cookies hasn't been provided, only cookies marked essential are sent to the browser. The following code makes a cookie essential:
[!code-csharpMain]
<a name="tempdata"></a>
The TempData provider cookie isn't essential. If tracking is disabled, the TempData provider isn't functional. To enable the TempData provider when tracking is disabled, mark the TempData cookie as essential in Startup.ConfigureServices:
[!code-csharpMain]
Session state cookies are not essential. Session state isn't functional when tracking is disabled. The following code makes session cookies essential:
<a name="pd"></a>
ASP.NET Core apps created with individual user accounts include code to download and delete personal data.
Select the user name and then select Personal data:
Notes:
Account/Manage code, see Scaffold Identity.AspNetUserTokens are deleted when the user is deleted via the cascading delete behavior due to the foreign key.Some databases and storage mechanisms allow for encryption at rest. Encryption at rest:
For example:
For databases that don't provide built-in encryption at rest, you may be able to use disk encryption to provide the same protection. For example: