473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ASP.NET Output caching question: does it cache the contents of System.Net.HttpWebRequest 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(string url)
{
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
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 1792
Make it as a User Control, mark it as <%@ OutputCache Duration="120"
VaryByParam="None" %>
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*****@newsgroup.nospamwrote in message
news:60**********************************@microsof t.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(string url)
{
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
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 "OutputCacheModule" 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****@microsoft.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*****@newsgroup.nospam>
Subject: ASP.NET Output caching question: does it cache the contents of
System.Net.HttpWebRequest 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(string url)
{
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
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
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. ...
1
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...
2
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)...
0
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...
3
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...
2
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...
3
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...
0
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));...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.