//< HttpClient >
WebRequestHandler handler = new WebRequestHandler();
//*< not working >
//0:
//*handler.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); //.BypassCache);
//*</ not working >
handler.AllowAutoRedirect = false;
HttpClient httpClient = new HttpClient(handler);
//httpClient.DefaultRequestHeaders.Add("Cache-Control", "no-cache, no-store, must-revalidate");
//httpClient.DefaultRequestHeaders.Add("Cache-Control", "public");
//httpClient.DefaultRequestHeaders.Add("Cache-Control", "private");
//*< not working >
//1:
//*httpClient.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
//2:
//*httpClient.DefaultRequestHeaders.CacheControl.NoStore = true;
//3:
//CacheControlHeaderValue cacheControl = new CacheControlHeaderValue();
//cacheControl.NoCache = true;
//httpClient.DefaultRequestHeaders.CacheControl = cacheControl;
//*</ not working >
string sHTML = ""; //Client Request as string
try
{
sHTML = await httpClient.GetStringAsync(new Uri(sURL));
}
catch (Exception ex)
{
//clsSys.show_Message(ex.Message);
clsSys.fx_Log("Error httpClient: " + ex.Message);
return null;
}
//</ HttpClient >
//-</ init >-
//< WebRequest and Response >
WebRequest objRequest = WebRequest.Create(sURL);
objRequest.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
//</ WebRequest and Response >
//< Stream and Reader >
Stream objDataStream = objResponse.GetResponseStream();
StreamReader TextReader = new StreamReader(objDataStream);
//</ Stream and Reader >
|