Skip to content

Avoid caching MediaTypeHeaderValue that is not serializable #165

@micdenny

Description

@micdenny

In general every class that is not a POCO class should not be cached, otherwise it becomes difficult to implement a caching provider based on a distributed caching system.

I'm developing an extension for AppFabric (the same will be when I will implement the Redis extension), and I'm blocked because CacheOutputAttribute tries to put in cache a .net framework object MediaTypeHeaderValue that is not serializable.

If caching that whole object is necessary we should think to use a POCO class instead, that share the same structure:

public class MyMediaTypeHeaderValue
{
        public string CharSet { get; set; }
        public string MediaType { get; set; }
        public List<NameValueHeaderValue> Parameters { get; set; }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions