dotnet / systemweb-adapters

MIT License
332 stars 58 forks source link

HttpResponseBase.Cache is typed incorrectly as HttpCachePolicy; Causes MissingMethodException #476

Closed AvremelM closed 1 week ago

AvremelM commented 5 months ago

Describe the bug

Currently, HttpResponseBase.Cache is typed as HttpCachePolicy. It should be HttpCachePolicyBase (a type that doesn't yet exist in SystemWebAdapters). See referencesource

To Reproduce

// in .netstandard2.0 library
public void TestMethod()
{
    HttpResponseBase responseBase = new HttpResponseWrapper(HttpContext.Current.Response);
    responseBase.Cache.SetCacheability(HttpCacheability.NoCache);
}

// In ASP.NET Framework application
TestMethod();

Exceptions (if any)

System.MissingMethodException: Method not found: 'System.Web.HttpCachePolicy System.Web.HttpResponseBase.get_Cache()'.

This exception happens at runtime.