473,725 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB caching the html rendered by a .aspx page

Hi,

My goal is to take the entire html/javascript stream spat out by .aspx pages
and save them as simple strings in a database (for caching purposes).

I'm not sure how I can get hold of this html stream, though - does anyone
have any strategies / code samples to get me going?

Thanks,

JON


Nov 18 '05 #1
10 1429
Try something along these lines. I haven't tested this but it should point
you in the right direction
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

Dim _stringBuilder As StringBuilder = New StringBuilder()
Dim _stringWriter As StringWriter = New StringWriter(_s tringBuilder)
Dim _htmlWriter As HtmlTextWriter = New HtmlTextWriter( _stringWriter)
MyBase.Render(_ htmlWriter)
Dim html As String = _stringBuilder. ToString()

'here is where you can manipulate or save the html string

writer.Write(ht ml)

End Sub

"Jon Maz" <jo****@surfeu. de.no.spam> wrote in message
news:Ok******** *****@TK2MSFTNG P12.phx.gbl...
Hi,

My goal is to take the entire html/javascript stream spat out by .aspx pages and save them as simple strings in a database (for caching purposes).

I'm not sure how I can get hold of this html stream, though - does anyone
have any strategies / code samples to get me going?

Thanks,

JON

Nov 18 '05 #2
You know, ASP.NET's OutputCache directive is VERY powerfull and does what
you are looking for. Check it out first.
"Jon Maz" <jo****@surfeu. de.no.spam> wrote in message
news:Ok******** *****@TK2MSFTNG P12.phx.gbl...
Hi,

My goal is to take the entire html/javascript stream spat out by .aspx pages and save them as simple strings in a database (for caching purposes).

I'm not sure how I can get hold of this html stream, though - does anyone
have any strategies / code samples to get me going?

Thanks,

JON

Nov 18 '05 #3
Hi All,

Thanks for the replies.

I really *do* need to cache entire pages of html/javascript to a db - the
number of pages involved is too great to cache in server memory, which is
what (if I understand correctly) the built-in asp.net caching does. So it
looks like I need some kind of custom solution here (feel free to correct me
if I'm wrong about this).

The site, which is for a publishing company, will use a Content Management
System to input dynamic content directly into the db. When the CMS user (a
journalist) is creating new page content via the CMS, he should have the
option to cache this new page immediately, ie before any site user has
viewed the .aspx page in a browser.

Now I'm really not sure how to go about this. An aspx page has a public
RenderControl method - should I be looking to use that somehow?

Any help appreciated,

Cheers,

JON

PS Also I'm not sure what the machine.config ProcessModel can do for me
(Jayson's suggestion in microsoft.publi c.dotnet.framew ork). Can anyone
elucidate?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004
Nov 18 '05 #4
Here's the thing, Jon. ASP.Net was architected in a certain way, and runs
optimally when you use it that way. If you want to redesign the entire
architecture, you're certainly free to do so. You can build your own
HttpHandler if you want, starting all the way from the bottom. The CLR has
everything you need.

You think your app is too big for ASP.Net to handle the way it is designed?
Think again. Microsoft uses it on their web site. It was designed for
immense scalability. If you use it the way it was designed to be used, it
will certainly scale to your needs without you having to re-write the
platform.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Jon Maz" <jo****@surfeu. de.NOSPAM> wrote in message
news:eF******** *****@tk2msftng p13.phx.gbl...
Hi All,

Thanks for the replies.

I really *do* need to cache entire pages of html/javascript to a db - the
number of pages involved is too great to cache in server memory, which is
what (if I understand correctly) the built-in asp.net caching does. So it
looks like I need some kind of custom solution here (feel free to correct me if I'm wrong about this).

The site, which is for a publishing company, will use a Content Management
System to input dynamic content directly into the db. When the CMS user (a journalist) is creating new page content via the CMS, he should have the
option to cache this new page immediately, ie before any site user has
viewed the .aspx page in a browser.

Now I'm really not sure how to go about this. An aspx page has a public
RenderControl method - should I be looking to use that somehow?

Any help appreciated,

Cheers,

JON

PS Also I'm not sure what the machine.config ProcessModel can do for me
(Jayson's suggestion in microsoft.publi c.dotnet.framew ork). Can anyone
elucidate?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004

Nov 18 '05 #5
Hi Kevin,

You may well be right, but unfortunately the design of the app is not going
to be my decision! The company is porting an existing web app / CMS from
Classic Asp into asp.net, and the Classic Asp version cached html/javascript
strings into a db. They've told me to go and find out how to replicate this
in asp.net.

If I *also* come back with some brand new ideas about new caching methods
that might serve better, then great, but my boss won't be too amused if I
tell him I simply have no idea how to replicate this existing caching
technique that always worked well for them. In fact the starting point of
my research was (of course) the built-in caching objects in .net. My boss's
response to articles on asp.net Caching (like
http://aspnet.4guysfromrolla.com/articles/022802-1.aspx) was to say "we have
over 30,000 articles to display on our site, you can't keep all that in
server memory".

Perhaps I/he misunderstand how asp.net caching works, and it *doesn't* work
by storing all cached data (in this case, 30,000+ articles) in memory. If
so, great - maybe someone can explain to me how it does work.

But anyway, the task I've been given is find out how to cache
html/javascript strings into a db using asp.net. Is it really the case that
I'd have to build my own HttpHandler to do this?! Hope not....

Thanks for the help so far,

JON


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004
Nov 18 '05 #6
Jon,
The code I provide in my previous post above will give you the actual
html/javascript of the rendered page which you can save to a database. The
remaining task of calling the page from the database instead of
re-renderering the page would have to be built but could be based on the
parameters of the data you save the database.
"Jon Maz" <jo****@surfeu. de.NOSPAM> wrote in message
news:uL******** ******@TK2MSFTN GP10.phx.gbl...
Hi Kevin,

You may well be right, but unfortunately the design of the app is not going to be my decision! The company is porting an existing web app / CMS from
Classic Asp into asp.net, and the Classic Asp version cached html/javascript strings into a db. They've told me to go and find out how to replicate this in asp.net.

If I *also* come back with some brand new ideas about new caching methods
that might serve better, then great, but my boss won't be too amused if I
tell him I simply have no idea how to replicate this existing caching
technique that always worked well for them. In fact the starting point of
my research was (of course) the built-in caching objects in .net. My boss's response to articles on asp.net Caching (like
http://aspnet.4guysfromrolla.com/articles/022802-1.aspx) was to say "we have over 30,000 articles to display on our site, you can't keep all that in
server memory".

Perhaps I/he misunderstand how asp.net caching works, and it *doesn't* work by storing all cached data (in this case, 30,000+ articles) in memory. If
so, great - maybe someone can explain to me how it does work.

But anyway, the task I've been given is find out how to cache
html/javascript strings into a db using asp.net. Is it really the case that I'd have to build my own HttpHandler to do this?! Hope not....

Thanks for the help so far,

JON


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004

Nov 18 '05 #7
Hi Mike,

Thanks for that, I'll see what I can do on the basis of your code snippet.
Do you have any suggestions for how to call the page from the db?

The other thing I'm currently musing on is how to access the different html
streams for different browsers. Do you know at what point the
HtmlTextWriter checks which browser it is producing html for, and can you
"pass a browser type as a parameter" to it?

Thanks again,

JON


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004
Nov 18 '05 #8
Your task sounds daunting and the potential for problems seems high. It may
be worth doing some benchmarking with test data and see if reading from the
database is faster than creating the pages on the fly. You might also do
some testing with the built in cache (Remember that you can cache the data
source, in whole or in part, and lots of other things like controls as well
as caching output pages). Maybe those test might be useful in convincing
others that the approach in dotnet should be different than asp. I don't
have enough experience to tell you which way to go on it, but you should be
able to use the code to save some pages and show that it can be done and you
can use that info to do the testing. There are a lot of others on the
newsgroup with a lot of experience that may have futher input.

Good Luck

"Jon Maz" <jo****@surfeu. de.NOSPAM> wrote in message
news:On******** ******@TK2MSFTN GP11.phx.gbl...
Hi Mike,

Thanks for that, I'll see what I can do on the basis of your code snippet.
Do you have any suggestions for how to call the page from the db?

The other thing I'm currently musing on is how to access the different html streams for different browsers. Do you know at what point the
HtmlTextWriter checks which browser it is producing html for, and can you
"pass a browser type as a parameter" to it?

Thanks again,

JON


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004

Nov 18 '05 #9
....continuing the debate...

Jon, caching the final output back to the db is putting even MORE strain on
the database machine... even if you use a caching server, ie a completely
separate database machine to hold the cached pages, you'll still never reach
local, in-memory caching performance.

Scalability of that solution is similar, however, IMO buying more RAM for
web servers and adding more webservers to the front line is a lot cheaper
and easier to maintain system then forcing a database backend to cache the
result.

Your client should respect your knowledge in .Net, and acknowledge the fact
that ASP.Net is almost completely different from Classic ASP, and in some
cases is over 10 times faster, even before using caching of any type...

....just my two cents...

--
Eric Newton
eric.at.ensoft-software.com
www.ensoft-software.com
C#/ASP.net Solutions developer

"Jon Maz" <jo****@surfeu. de.no.spam> wrote in message
news:Ok******** *****@TK2MSFTNG P12.phx.gbl...
Hi,

My goal is to take the entire html/javascript stream spat out by .aspx pages and save them as simple strings in a database (for caching purposes).

I'm not sure how I can get hold of this html stream, though - does anyone
have any strategies / code samples to get me going?

Thanks,

JON

Nov 18 '05 #10

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

Similar topics

2
1572
by: CJM | last post by:
I have an application that I'm developing that generates a PDF from an HTML page. The quotation.htm page is generated manually, but will be automated in the finished version. It is processed in PDFTest.asp using an off-the-shelf PDF component, which creates Test.pdf. I am having problems with caching: if I change the content of the html page, it is generally not being reflected in the finished PDF. I've modified the HTTP Headers (in...
2
3967
by: Stephen Miller | last post by:
I have an ASPX report and I want to capture the rendered HTML and write to a file on the webserver. Several posts suggest using WebRequest to make a second call to the page, and screen-scrape the resulting HTML. The technique typically described is: '-- Get the current URL and request page Dim url As String = System.Web.HttpContext.Current.Request.Url.AbsoluteUri Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url)
3
1524
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink for every entry in my table. So i query the database and get for example 3 entries back. So in a while loop i can make 3 hyperlinks with response.write(.......) etc.
10
4395
by: Umut Tezduyar | last post by:
It seems, it is caching it. The following code is an example for it. How can avoid from this. override void OnLoad (sender and eventargs) { Control control = this.LoadControl (path); this.Controls.Add (control); // I change the content of the html of the control. TextReader reader = new StreamReader (path);
2
1727
by: Ken Cox - Microsoft MVP | last post by:
I'm trying to find a way to program in ASP.NET 2.0 but capture the HTML output. I found the following routine in ASP.NET 2.0 Cookbook from O'Reilly. It doesn't work if I include a server-side dropdownlist control on the page. The error is RegisterForEventValidation can only be called during Render(); Any ideas? Ken Microsoft MVP
4
2196
by: orianavim | last post by:
Hi, I'm try to find an easy efficient way to generate my web pages dynamically from an xml/text file. What exactly I want? I want that whenever a pages is loaded it will go and read an xml/text file which will include the style of the page (tables,div, web controls, etc) and will build the page according to that. Meaning that
5
1361
by: homertbush | last post by:
When our asp.net pages are rendered out as html the page directive is still in the html. ie. The following page directive is present in the body of the html of the rendered page: <%@ Page CodeBehind="about.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Briggs.about" %> <%@ Register TagPrefix="uc1" TagName="WebUserControlSearch" Src="WebUserControlSearch.ascx" %>
3
1755
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 -...
2
1835
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
8889
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
9257
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
9179
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,...
1
6702
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
6011
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
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
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
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.