Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVC: The default ITempDataProvider is now CookieTempDataProvider #225

Open
ryanbrandenburg opened this issue Mar 3, 2017 · 0 comments
Open

Comments

@ryanbrandenburg
Copy link
Member

ryanbrandenburg commented Mar 3, 2017

Summary

The default ITempDataProvider is now CookieTempDataProvider (previously it was SessionStateTempDataProvider). This was done to avoid having to configure session state for basic usage.

As is usual with our announcements, this thread is locked to avoid spamming users subscribed to aspnet/Home. Use aspnet/Mvc#5893 for discussion and questions.

Impact

We expect that for most usage of TempData this will be a relatively seemless change, however if you make heavy use of TempData you may want to consider using SessionStateTempDataProvider.

If you wish to keep using SessionStateTempDataProvider then you must include the SessionStateTempDataProvider services and Session middleware as in the snippet below.

public void ConfigureServices(IServiceCollection services)
{
    service.AddMvc()
           .AddSessionStateTempDataProvider();
    services.AddSession(o =>
    {
        ...
    });
}

public void Configure(IApplicationBuilder app)
{
    // UseSession must appear before UseMvc
    app.UseSession();
    app.UseMvc();
}

Choosing between cookie and session

CookieTempDataProvider is simple to set up, but browsers put limits on the size of cookies and on the number of cookies that can be stored per-site. If you're storing lots of data you may want to use SessionStateTempDataProvider.

We do not recommend storing sensitive information in TempData. As defense in depth, CookieTempDataProvider uses DataProtection to encrypt the values stored in TempData. SessionStateTempDataProvider is the most secure option since it keeps data on the server.

@aspnet aspnet locked and limited conversation to collaborators Mar 3, 2017
@rynowak rynowak changed the title The default ITempDataProvider is now CookieTempDataProvider MVC: The default ITempDataProvider is now CookieTempDataProvider Mar 3, 2017
@rynowak rynowak added this to the 2.0.0 milestone Mar 3, 2017
@danroth27 danroth27 added 2.0.0 and removed 2.0.0 labels Aug 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants