473,608 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebRequest ignoring cache

First of all, I apologize. I wanted to post this in
microsoft.publi c.dotnet.framew ork (as it's a bit more appropriate there),
but Outlook Express is suddenly giving me errors whenever I go to that
newsgroup and I have to restart OE.

I'm using WebRequest and I want to bypass any caching in the proxy server.
Unfortunately, I don't have a proxy to test with.

My understanding is that I just need to pass a pragma: no-cache and
cache-control: no-cache (to avoid caching in the first place) in the header.
Do I simply add the headers as shown in the code below? Or do I need to do
something else?

WebRequest req = WebRequest.Crea te(url);
if (null != proxy)
{
req.Proxy = proxy;
}
using (WebResponse response = req.GetResponse ())
{
req.Headers.Add ("pragma", "no-cache");
req.Headers.Add ("cache-control", "no-cache");
using (Stream stream = response.GetRes ponseStream())
{...
Thanks.

Pete
Nov 16 '05 #1
1 10016
Nevermind, figured it out from a second google search. I must have
misspelled something in the first because I was getting completely offtopics
responses.

Anyway, the code I guess was right except that I should be using
req.Headers.Set () instead of add. I'm not sure it matters, but that's what
the sample code did.

Pete

"Pete Davis" <pd******@NOSPA M.hotmail.com> wrote in message
news:iu******** ************@gi ganews.com...
First of all, I apologize. I wanted to post this in
microsoft.publi c.dotnet.framew ork (as it's a bit more appropriate there),
but Outlook Express is suddenly giving me errors whenever I go to that
newsgroup and I have to restart OE.

I'm using WebRequest and I want to bypass any caching in the proxy server.
Unfortunately, I don't have a proxy to test with.

My understanding is that I just need to pass a pragma: no-cache and
cache-control: no-cache (to avoid caching in the first place) in the header. Do I simply add the headers as shown in the code below? Or do I need to do
something else?

WebRequest req = WebRequest.Crea te(url);
if (null != proxy)
{
req.Proxy = proxy;
}
using (WebResponse response = req.GetResponse ())
{
req.Headers.Add ("pragma", "no-cache");
req.Headers.Add ("cache-control", "no-cache");
using (Stream stream = response.GetRes ponseStream())
{...
Thanks.

Pete

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3218
by: William F. Robertson, Jr. | last post by:
I am having problems with using the WebRequest object (or HttpWebRequest ). I have created the WebRequest and set the credentials, but when I call GetResponse() it is throwing an internal server error 500 on me. I am running a console app on my sql server that is trying to create a WebRequest to my Webserver to notify the cache on the webserver to refresh itself. The website is using NT authentication. The user I am using is in the...
1
3161
by: Dave | last post by:
I'm trying to make a webrequest to another server on our webfarm (to synch the cache as explained in http://www.eggheadcafe.com/articles/20030420.asp) but I'm getting a 401 unauthorized error. We are using service accounts for the app to run under which I thought would work in setting the webrequest's credentials property but with no luck.... HttpWebRequest req = (System.Net.HttpWebRequest)WebRequest.Create(sFullUri); req.Method =...
0
3869
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use tools like ieHTTPHeaders v1.6, and I perform a normal login (using the normal website), I see that the viewstate is __VIEWSTATE=dDwxMzU4OTE3NTA2Ozs%2BTK88jS63JXN181X3N8zKivua8co%3D&txt_username=xxx&txt_password=xxxxxx&btn_login=Login. When I...
6
1700
by: matt | last post by:
hello, i am having trouble doing something. when a user triggers a certain event in my app, i need to initiate another web request to one of my other webpages, programmatically. currently, i do this via a WebRequest -- i attach the default credentials and get the response stream. that part works. like so: WebRequest request = HttpWebRequest.Create(reportAspxURL); request.Credentials = CredentialCache.DefaultCredentials;
2
3783
by: soul_chicken | last post by:
I'm working on a simple image upload project using the asp:FileUpload control. I read the file in and stick it into a clients content management system. The problem is that once I redirect back to a view page, the cached copy of the image from the content management system is being returned. Hit "F5" and everything comes back as intended. I can't make changes to the content management system but I would like to eliminate the extra...
0
1206
by: Stan SR | last post by:
Hi, I use a repeater that calls a page where I display an image (sorry for my english ;) ) This page performs a webRequest to capture a jpg file And with the result I resize the picture and make OutputStream I have 2 questions :
4
1378
by: Supremelink | last post by:
Hi all, I have a (in my opinion) strange problem. I created an application that are extracting exchange rates from a web page and then inserts those in a ms sql database. When I´m running this application on my local machine, everything works fine. All rates are updated. But when I run it on the server, it ´s always gets the same result. No update at all. It´s like the result are cached or something.
2
1818
by: Ken Fine | last post by:
I have a question about ASP.NET output caching. I want to use screen scraping as a temporary hack to pull in some complex Classic ASP-rendered content into some ASP.NET pages: protected String ReadHtmlPage(string url) { WebResponse objResponse; WebRequest objRequest = System.Net.HttpWebRequest.Create(url); objResponse = objRequest.GetResponse();
0
8011
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8503
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8488
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8160
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6826
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3972
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.