empz
empz

Reputation: 11788

How to remove or change ASP.NET MVC 5 default cookie

I've created an ASP.NET MVC 5 application with "Individual User Accounts" (OWIN). I'm following this guide to remove unnecessary HTTP headers that exposes stuff I don't want to expose.

Everything was removed properly but there's one extra thing that's revealing this is an ASP.NET application which is the default cookie:

Cookie:ASP.NET_SessionId=gpryojsaen2hnukmzoh5xbuv;

Is there a way to change the name to something else?

Upvotes: 1

Views: 2828

Answers (2)

Brad Christie
Brad Christie

Reputation: 101614

Given you're using OWIN, you should be able to change the setting in your app.UseCookieAuthentication call. Something like:

public void ConfigureAuth(IAppBuilder app)
{
    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        CookieName = "ChangeMe",
        /* other options */
    });
}

Upvotes: 3

empz
empz

Reputation: 11788

I neded to add this to the web.config

<system.web>
    <sessionState cookieName="foo" />
</system.web>

Upvotes: 4

Related Questions