locked
is DefaultCachePolicy property in WebRequest missing in VS2013 C# preview? RRS feed

  • Question

  • The property is not recognized. Is this a known issue? I need to use that property. Is there anything I can do instead to set the cache policy for my outgoing requests?
    • Moved by CoolDadTx Wednesday, September 4, 2013 5:43 PM WinRT related
    Tuesday, September 3, 2013 9:05 AM

All replies

  • Hello,

    Thanks for your posting.

    From your description, I know that you found the DefaultCachePolicy property of WebRequest was not recognized in visual studio 2013 preview.

    I just tested this in Visual studio 2013 preview and it works fine on my end. Here is what I did for your reference:

    1. Create a simple console application.
    2. Added the following references: System.Net and System.Net.Cache.
    3. Using the following namespaces and check the DefaultCachePolicy property.

                      using System.Net ;

                     using System.Net.Cache;

                     …

                     WebRequest.DefaultCachePolicy = new RequestCachePolicy();

                     …

    Please try above steps and let me know if it works for you.

    Hope these help.


    Lilia Gong <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 4, 2013 7:21 AM
  • Thank you,

    Your scenario for a console app works for me too, but what I didn't mention is that my project from which I'm trying to use that property is a Windows Runtime Component project. And from there, the property is still not available. Why is that?

    To be more specific - I have a WinRT component from which I'm making an XDocument.Load(someUrlOverTheNet) operation. I want the request header to have NoCacheNoStore. From what I read, I need to set the WebRequest.DefaultCachePolicy property, but I can't seem to have access to it.

    Wednesday, September 4, 2013 9:43 AM
  • That property is not supported in WinRT.  Please refer to the documentation here.  Please post WinRT related questions in the Windows Store forums.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    Wednesday, September 4, 2013 5:42 PM