Closed kedzior-io closed 5 years ago
This is probably because the cookie for the temp data provider isn't marked as essential and you haven't wired up the cookie consent pieces. Please take a look at https://docs.microsoft.com/en-us/aspnet/core/security/gdpr?view=aspnetcore-2.1 and try integrating that.
We're closing this issue as no response or updates have been provided in a timely manner. If you have more details and are encountering this issue please add a new reply and re-open the issue.
Yeah, sorry about responsiveness and thanks for your time. Read the document and so what I understand is that to disabled GDPR but still use TempData I do the following:
services.Configure<CookiePolicyOptions>(options => {
options.CheckConsentNeeded = context => false; // ignore user's consent
options.MinimumSameSitePolicy = SameSiteMode.None;
});
...
services.Configure<CookieTempDataProviderOptions>(options => {
options.Cookie.IsEssential = true; // mark it as essential
});
...
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseMvc();
That still won't work.
Ok that seems my bad. The above configuration works.
While editing template I didn't add
@await Html.PartialAsync("_StatusMessage", Model.StatusMessage)
to the particular view I was testing.
When using scaffolded asp.net core 2.1 identity:
services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1) .AddCookieTempDataProvider();
services.AddSession();
is placed AFTERservices.AddMvc();
Apparently the order doesn't matter.
I have tested it with scaffolded index page of the profile:
Areas.Identity.Pages.Account.Manage.Index.cshtml.cs
Updating phone number sets TempData property:
StatusMessage = "Your profile has been updated";
But it's not rendered in the view:
@Html.Partial("_StatusMessage", Model.StatusMessage)