예제 #1
0
        public async Task Refuse_cached()
        {
            var client = CreateClientWithMessageHandlerCache();

            var response = await client.GetAsync("/CacheableResource"); // Round trip to server

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            HttpAssert.FromServer(response);

            var request = new HttpRequestMessage()
            {
                RequestUri = new Uri("/CacheableResource", UriKind.Relative)
            };

            request.Headers.CacheControl = new CacheControlHeaderValue()
            {
                NoCache = true
            };

            var response2 = await client.SendAsync(request);

            Assert.Equal(HttpStatusCode.OK, response2.StatusCode);
            HttpAssert.FromServer(response2);
        }