473,842 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET Output caching question: does it cache the contents of System.Net.Http WebRequest requests

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(st ring url)
{
WebResponse objResponse;
WebRequest objRequest = System.Net.Http WebRequest.Crea te(url);
objResponse = objRequest.GetR esponse();
StreamReader sr = new StreamReader(ob jResponse.GetRe sponseStream()) ;
return sr.ReadToEnd();
}

I am wondering if ASP.NET output caching will also cache what's pulled via
this method (I am hoping so; if not, I don't think this will be sufficiently
performant.)

Thanks,
-KF

Sep 17 '08 #1
2 1845
Make it as a User Control, mark it as <%@ OutputCache Duration="120"
VaryByParam="No ne" %>
Then the output of that UserControl will be cached for 120 seconds. And
your code will not be even hit for 120 seconds

George.

"Ken Fine" <ke*****@newsgr oup.nospamwrote in message
news:60******** *************** ***********@mic rosoft.com...
>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(st ring url)
{
WebResponse objResponse;
WebRequest objRequest = System.Net.Http WebRequest.Crea te(url);
objResponse = objRequest.GetR esponse();
StreamReader sr = new StreamReader(ob jResponse.GetRe sponseStream()) ;
return sr.ReadToEnd();
}

I am wondering if ASP.NET output caching will also cache what's pulled via
this method (I am hoping so; if not, I don't think this will be
sufficiently performant.)

Thanks,
-KF
Sep 17 '08 #2
Hi KF,

As for the output caching, based on my understanding, it is controlled by
the "OutputCacheMod ule" httpmodule. You can find it in the machine level
web.config in the framework directory.

Generally, as long as the content (you manually added) are write out into
the page's response stream and the ASP.NET page's request pipeline executed
completely, the output cache will also work. But you need to take care that
you doesn't manually close the request/context or modify any certain http
header that may change the cache behavior(or impact the cache httpmodule's
code logic)

BTW, If you have a large text content(need cache) to present via ASP.NET
page, I think you can also use a dedicated httphander, and in handler you
can programmtically use Cache collection to cache the certain content.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/...tance&ln=en-us.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Ken Fine" <ke*****@newsgr oup.nospam>
Subject: ASP.NET Output caching question: does it cache the contents of
System.Net.Http WebRequest requests
>Date: Tue, 16 Sep 2008 17:29:56 -0700

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(st ring url)
{
WebResponse objResponse;
WebRequest objRequest = System.Net.Http WebRequest.Crea te(url);
objResponse = objRequest.GetR esponse();
StreamReader sr = new StreamReader(ob jResponse.GetRe sponseStream()) ;
return sr.ReadToEnd();
}

I am wondering if ASP.NET output caching will also cache what's pulled via
this method (I am hoping so; if not, I don't think this will be
sufficiently
>performant.)

Thanks,
-KF

Sep 17 '08 #3

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

Similar topics

0
2143
by: Martin | last post by:
Hi. I had a very frustrating afternoon and evening but I have got it all under control now so all of a sudden I am in a good mood. I want to share some insights on output caching with you lot. After looking at the use of the OutputCache directive and tinkering with it a bit I found its usability.very limited. Think of it: it is okay for static content. Well that's nice but no big deal. Static content is cheap anyway, the file system...
1
1322
by: Gavin Pollock | last post by:
Is anyone using Caching (HttpRuntime.Cache) in Whidbey? Not sure if there's another newsgroup for this though since it's still beta.... I'm having issues running a system built on 1.1 in a 2.0 environment... Simple (I think!!) use of the Cache as below, BOSContext bosContext = new BOSContext(); StringBuilder Html = new StringBuilder();
2
1901
by: Hadar | last post by:
Hi, We have IIS 6.0 servers and we want to take advatage of the kernel-mode caching feature by using output cache directive in certain pages. As far as I understand, IIS saves for each (unique) request the appropriate response... When the page is first loaded, followed by GET request, there is one response for all users. But the problems starts when the user submits the form (POST) - the response could not be a static cached page,...
0
1760
by: Rick Hein | last post by:
I've got a problem with an app I've been working on, the Caching object and events not firing correctly. In a nutshell: When I'm debugging, and I set a breakpoint in the removed item call back, the code works correctly. If there is no debugger it doesn't fire, which causes the app to have problems. Here's what the code does: The TemplateData class inherits from the DataSet Object, in the constructor it loads itself with Data from an XML...
3
6463
by: ary | last post by:
I try to create a weblog host site! in this case i can't use cache for every page because that cause to be my Server ram full of caching page. but if I can save cache in hard disk my problem solved? can help me? thanks.
2
2191
by: aptenodytesforsteri | last post by:
I have an ASP.NET 2.0 application I've localized to English, French, German, and Italian. I used resource (.resx) files. Most of the site is static content, easily 90% of it, so I thought output caching would be useful. I implemented output caching at 60 seconds.
3
1759
by: Smithers | last post by:
Just wondering what it would take to cache a copy of the output HTML from a dynamically constructed aspx page before it is sent to the browser. Reason being: the page is constructed of a few user controls, each of which queries a SQL Server database for their content. The content is not likely to change frequently at all - so I'd like a way to cache the final page upon first request. Then subsequent requests are served from the cache -...
0
1389
by: Jordan S. | last post by:
Using .NET 3.5... in a "plain old" .aspx page I have the following code in the Init event: this.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); this.Context.Response.Cache.SetCacheability(HttpCacheability.Public); this.Context.Response.Cache.SetValidUntilExpires(false); It works great. Testing shows that the page is cached for 60 seconds as expected. Specifically, I insert the current date/time into the Response...
2
3169
by: Peter | last post by:
Hi The documentation for System.Web.Caching.Cache states that it is "thread safe". Does this mean that if I access System.Web.Caching.Cache from several places in my application access to the items in the cache is synchronised so I don't get problems with setting/getting the same item at the same time?
0
9875
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10614
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...
0
9454
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
7859
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
7040
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5697
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...
0
5886
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4500
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
3
3146
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.