Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

windows phone 7 - WP7 HttpWebRequest without caching

It seems that HttpWebRequest caching in WP7 is enabled by default, how do I turn it off? Adding a random param url + "?param=" + RND.Next(10000) works, but it's quite tricky and I'm not sure if it will work with all servers.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For future reference , this worked for me ( I could not use additional query parameter due to project requirements) :

        HttpWebRequest request = HttpWebRequest.CreateHttp(url);
        if (request.Headers == null)
        {
            request.Headers = new WebHeaderCollection();
        }
        request.Headers[HttpRequestHeader.IfModifiedSince] = DateTime.UtcNow.ToString();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...