Got in a difficult situation of storing and retrieving TextReader in
Cache, but found no such post yet.
Tried to store a textreader into Cache object in a similar way
illustrated in .NET's SDK doc ("Retrieving Values of Cached Items"):
' -----------------------------
...
Dim CPCache As textreader = CType(Cache("CP"), textreader)
If CPCache Is Nothing Then
...
Dim txtrd As TextReader = ... ' get something to fill the txtrd.
Cache.Insert("CP", txtrd)
' display txtrd's content on the page
divTag.InnerText = "New!!! " & txtrd.ReadtoEnd
Else
divTag.InnerText = "Cache exists! " & CPCache.ReadtoEnd
End If
' -----------------------------
Web page displayed the txtrd content when it ran the first time as:
New!!! ..... (content of txtrd, all normal char as expected)
Then showed:
Cache exists!
It's verified the length of CPCache's content is zero in Cache. But no
error returned.
However, replacing "txtrd" (TextReader) with "str" (string) and
appropriate methods, content of "str" is shown correctly following
"Cache exists! " on the page.
Does anyone have any experience of TextReader in Cache?
Thanks. 3 1424
Hello
I think you need to rewind the text reader every time you use it. Anyways I
I don't understand why do you store the text reader in cache, because in
this case you are only storing a pointer to a stream. Caching the content
you read from the textreader may be a better way.
Best regards
Sherif
"Chan" <hi*****@yahoo.com> wrote in message
news:fe**************************@posting.google.c om... Got in a difficult situation of storing and retrieving TextReader in Cache, but found no such post yet.
Tried to store a textreader into Cache object in a similar way illustrated in .NET's SDK doc ("Retrieving Values of Cached Items"): ' ----------------------------- ... Dim CPCache As textreader = CType(Cache("CP"), textreader) If CPCache Is Nothing Then ... Dim txtrd As TextReader = ... ' get something to fill the txtrd. Cache.Insert("CP", txtrd) ' display txtrd's content on the page divTag.InnerText = "New!!! " & txtrd.ReadtoEnd Else divTag.InnerText = "Cache exists! " & CPCache.ReadtoEnd End If ' -----------------------------
Web page displayed the txtrd content when it ran the first time as:
New!!! ..... (content of txtrd, all normal char as expected)
Then showed:
Cache exists!
It's verified the length of CPCache's content is zero in Cache. But no error returned.
However, replacing "txtrd" (TextReader) with "str" (string) and appropriate methods, content of "str" is shown correctly following "Cache exists! " on the page.
Does anyone have any experience of TextReader in Cache?
Thanks.
"Chan" <hi*****@yahoo.com> wrote in message
news:fe**************************@posting.google.c om... Got in a difficult situation of storing and retrieving TextReader in Cache, but found no such post yet.
Tried to store a textreader into Cache object in a similar way illustrated in .NET's SDK doc ("Retrieving Values of Cached Items"): ' ----------------------------- ... Dim CPCache As textreader = CType(Cache("CP"), textreader) If CPCache Is Nothing Then ... Dim txtrd As TextReader = ... ' get something to fill the txtrd. Cache.Insert("CP", txtrd) ' display txtrd's content on the page divTag.InnerText = "New!!! " & txtrd.ReadtoEnd Else divTag.InnerText = "Cache exists! " & CPCache.ReadtoEnd End If ' -----------------------------
Web page displayed the txtrd content when it ran the first time as:
New!!! ..... (content of txtrd, all normal char as expected)
Then showed:
Cache exists!
Once you've read to the end of your TextReader, it's done. You're at the
end. That's all there is.
David
In .Net document, "DataReader" is described as "forward-only", but
"TextReader" isn't.
Is it true that everything named "Reader" are forward-only like
"DataReader"?
Is there any non-forward-only class corresponding to "TextReader"?
Thanks! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve Binney |
last post by:
My code makes synchronous HttpWebRequest and HttpRebResponse calls. In VS
2003, I am getting memory leaks and event handle leaks. I am closing all
streams and using "using"statements. I have...
|
by: |
last post by:
I am rewriting a C++ application in C#. This file has a combination of Text
and Binary data.
I used CFile before to read the text. If I hit a certain string that
denotes the following data is...
|
by: Colin Green |
last post by:
Hi I wonder if anyone has any ideas about this...
I am dumping the contents of an XmlDocument into a RichTextBox so the
user can see the raw XML. I use a line of code something like this to
lado...
|
by: Fernando Chilvarguer |
last post by:
Hi,
I'm retriving data from a database and storing it on the Cache Object using
the following code:
HttpContext.Current.Cache.Insert(
cacheItemKey,
contentDS, //THE DATASET WITH MY DATA...
|
by: Bryan Dickerson |
last post by:
StreamReader says it is designed to read a stream of characters
StringReader says it is designed to read a string
TextReader says it is designed to read a sequential list of characters.
I hate...
|
by: trint |
last post by:
When testing locally with:
TextReader tr = new StreamReader(@"C:\gcc.set");
Now that I have uploaded this to the server on the net,
that locations permissions are denied.
How can I change this to...
|
by: Rene |
last post by:
Hi,
I decided to take a closer look at the TextWriter and TextReader abstract
classes just for fun.
While poking around, I noticed that the TextWriter class includes an
'Encoding' property in...
|
by: BizWorld |
last post by:
I am trying to cache a full DROP Down that can have lot of values. so
i have 500 site users hitting a page in a second. i need to cache some
controls that does not change quite often during the...
|
by: Tony Johansson |
last post by:
Hello!
I just wonder in this specific case is it any advantage to use a
TextReader a reference to a StreamReader ?
Try
{
TextReader tr = new StreamReader(locationTextBox.Text);
Try
{
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |