Skip to content

Not able to read cookie value with more specific path in .NET Core/5.0? #37431

Open
@SoftCircuits

Description

@SoftCircuits

It appears HttpCookie has been completely removed in .NET Core/5.0.

Moreover, if two cookies have the same name but different paths (let's say one path is /Folder and one path is /Folder/Subfolder), it seems to return the value for the cookie with the shorter path. This appears to run counter to at least the spirit put forth in RFC 6265, which in section 5.4, subsection 2 states:

The user agent SHOULD sort the cookie-list in the following order:

Cookies with longer paths are listed before cookies with shorter paths.
NOTE: Not all user agents sort the cookie-list in this order, but this order reflects common practice when this document was written, and, historically, there have been servers that (erroneously) depended on this order.

In my case, I am storing cookies using the path of the current page. But I just moved a page from /Folder to /Folder/Subfolder. And, because users will have cookies stored in the shorter path, .NET now provides no means for accessing the value with the more specific path. My code is broken and I don't see any workaround.

Shouldn't Request.Cookies[key] at least return the first matching value?

I just don't get the thinking behind the removal of this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions