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

K

Ken Fine

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
 
G

George

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.
 
S

Steven Cheng

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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#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/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Ken Fine" <[email protected]>
Subject: ASP.NET Output caching question: does it cache the contents of
System.Net.HttpWebRequest requests
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top