Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / April 2008

Tip: Looking for answers? Try searching our database.

HttpCachePolicy.SetLastModifiedFromFileDependencies Method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee C. - 15 Mar 2008 06:12 GMT
Hello.  I just discovered this method and tried it out.  It seems that the
CodeFile (.aspx.vb) is not considered a dependency; yet, if I chose to have
that same code in the .aspx page, altering it would change the Last-Modified
value.

Is this considered a bug?

Cordially,
Lee C.
Alvin Bruney [ASP.NET MVP] - 16 Mar 2008 02:08 GMT
Nope, that's by design if I understand you correctly.

It seems that the
> CodeFile (.aspx.vb) is not considered a dependency;
Where did you get this info from?

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> Hello.  I just discovered this method and tried it out.  It seems that the
> CodeFile (.aspx.vb) is not considered a dependency; yet, if I chose to
[quoted text clipped - 5 lines]
> Cordially,
> Lee C.
Lee C. - 16 Mar 2008 03:43 GMT
Thanks for the reply, Alvin.  I got that info from watching the HTTP
requests, in detail, with Fiddler2 (http://www.fiddlertool.com/fiddler/).

IMO, the design is flawed.  The CodeFile can alter the presentation; thus,
it should be considered when determining the Last-Modified.

If I put the presentation altering code in the .aspx page inside script
delimiters, when I save the file, it would affect the Last-Modified.  If I
take that same code and put it in the CodeFile and save it, the save does
not affect the Last-Modified.  That is illogical.

Cordially,
Lee C.

> Nope, that's by design if I understand you correctly.
>
[quoted text clipped - 11 lines]
>> Cordially,
>> Lee C.
Alvin Bruney [ASP.NET MVP] - 20 Mar 2008 01:19 GMT
Ok, I understand what you are saying - to rephrase, the dependency on the
aspx file works but the dependency on the codebehind file does not work,
right? The code beside files is of absolutely no use to the run-time, why
should there be a dependency on it? The contents of the file is compiled
into binary and placed in a temp location. Access to the types which were
defined in the file is occuring thru that temp binary at run-time - the code
file plays no part point forward.

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> Thanks for the reply, Alvin.  I got that info from watching the HTTP
> requests, in detail, with Fiddler2 (http://www.fiddlertool.com/fiddler/).
[quoted text clipped - 25 lines]
>>> Cordially,
>>> Lee C.
Lee C. - 20 Mar 2008 04:01 GMT
Alvin,

I appreciate your replies; but, I think we are not yet understanding one
another.

You wrote, "...to rephrase, the dependency on the aspx file works but the
dependency on the codebehind file does not work, right?"

The first part of that statement sounds like a circular reference to me.  I
am talking about the Last-Modified date of the .aspx page; so, are you
saying that the Last-Modified of the .aspx file is dependent on the .aspx
file?  :]  If so, I would not state it that way, but we seem to agree.

Regarding the second part of your statement, yes, I am saying that the HTTP
header's Last-Modified Date sent to the requesting host by way of the
HttpCachePolicy.SetLastModifiedFromFileDependencies method does not take
into account the file system's "Date Modified" of the code beside file.

You seem to be saying that this makes sense to you, because "The code beside
files is of absolutely no use to the run-time" ...and it has to do with how
the engine makes temp files...etc.  I disagree, wholeheartedly, about this
making sense, and so do Visual Studio and IIS.  I'll try to illustrate
below.

In Visual Studio (I'm using 2008), add a new Web Form item, and check the
"Place code in separate file" box.  You'll get a .aspx page with page
declaration including CodeFile="Default.aspx.vb" Inherits="_Default".  Go
ahead and delete the ..aspx.vb file since you feel that there is no
dependency on it, then try to build that page in VS 2008.  You'll get a
build errors, for the Default.aspx file, to the effect of:
1. Error 1 The file '/Default.aspx.vb' does not exist.
2. Error 2 'Context' is not a member of '_Default'.
That seems like a sign of dependency to me.

Without fixing those, request the .aspx page via a browser, and IIS will
tell you:
Parser Error Message: The file '/Default.aspx.vb' does not exist.
Source File: /ec/Default.aspx

Again, that seems like another sign of dependency to me.

I understand your technical explanation of how the ASP.NET engine uses my
developer design-time files to make temp files to serve to hosts.  That does
not change the fact that it is doing something wrong with respect to the
HttpCachePolicy.SetLastModifiedFromFileDependencies method.  It is not
taking into account the file system's "Date Modified" for the .aspx.vb--but,
it should.  (Your explanation regarding compiled temp files may make sense
to you, but consider it for a first time building/compiling/running of a Web
site versus after I make changes later.)

Let's look at this from a slightly different angle.  My real-world goal: I
am trying to get the HTTP header's Last-Modified Date, of my .aspx page,
which hosts request by name, to cache (publicly and/or privately) in a way
that makes sense, so that the host's agent can smartly determine if it may
reuse a cached version of my .aspx page--if it has not changed.  Whether or
not my .aspx page has changed certainly could--and should--depend upon
whether the code beside file has changed!  Why would I put code in the code
beside if it does not change the .aspx page?  For example,
TextBox1.Text = "We are no longer accepting reservations for today."

As I understand it, the code beside is simply an alternative place to store
syntax that could have been in the .aspx page.  (for the sake of separation)
That's why Microsoft gave me the option to check the "Place code in separate
file" box.  If I check the box, the code beside consequently must/should be
considered when determining what Last-Modified Date to send to the
requesting host--but it isn't.

If I do *not* check the "Place code in separate file" box when I add a new
Web Form item, forcing me to put my "code beside" code into my .aspx page
inside <% %> delimiters, the HTTP header's Last-Modified Date, via the
HttpCachePolicy.SetLastModifiedFromFileDependencies method, will always
reflect the file save date of changes to CLR code inside the <% %>
delimiters.

If I do use code behind and make the same code change, the
HttpCachePolicy.SetLastModifiedFromFileDependencies method will not take
into account the saving of those same CLR code changes, giving an outdated
HTTP header Last-Modified Date.  That should not be!

, Lee C.

> Ok, I understand what you are saying - to rephrase, the dependency on the
> aspx file works but the dependency on the codebehind file does not work,
[quoted text clipped - 33 lines]
>>>> Cordially,
>>>> Lee C.
Alvin Bruney [ASP.NET MVP] - 21 Mar 2008 21:09 GMT
Have a look at this kb article, its a long shot but there is a bug in the
method. See the fix works for you.
http://support.microsoft.com/kb/909643

Signature

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99

> Alvin,
>
[quoted text clipped - 116 lines]
>>>>> Cordially,
>>>>> Lee C.
Lee C. - 22 Mar 2008 16:56 GMT
Thanks, Alvin.  That KB article made me think for a minute.  I think that I
was focused on looking for the "correct" HTTP Last-Modified date, via
Fiddler, in my testing; i.e., I was separating the HTTP Last-Modified date
from whether it actually served a cached page or not.

I've done so much experimentation that I cannot recall for sure.  I'm going
to do some incremental troubleshooting/experimentation today or tomorrow.  I
will post my testing and findings.

Cordially,
Lee C.

> Have a look at this kb article, its a long shot but there is a bug in the
> method. See the fix works for you.
[quoted text clipped - 122 lines]
>>>>>> Cordially,
>>>>>> Lee C.
Lee C. - 23 Mar 2008 02:21 GMT
Okay, it seems that my original post was unnecessary!  I was originally
testing/implementing on a (production) hosting server, directly, which was
adversely affected by FTP client "touch" behavior not being supported by my
hosting company.

I started over just now, using my localhost IIS server, and the
HttpCachePolicy.SetLastModifiedFromFileDependencies method works just as I
desired.  It's even better, because I can easily use
Context.Response.AddFileDependency to create a dependency on any file I
choose.  I tried it with my CSS file, and it works great.  This is the type
of richness that I've come to expect from Microsoft, and they've delivered
once again.

Cordially,
Lee

> Thanks, Alvin.  That KB article made me think for a minute.  I think that
> I was focused on looking for the "correct" HTTP Last-Modified date, via
[quoted text clipped - 137 lines]
>>>>>>> Cordially,
>>>>>>> Lee C.
Alvin Bruney [ASP.NET MVP] - 02 Apr 2008 02:41 GMT
shweet!

Signature

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------

> Okay, it seems that my original post was unnecessary!  I was originally
> testing/implementing on a (production) hosting server, directly, which was
[quoted text clipped - 153 lines]
>>>>>>>> Cordially,
>>>>>>>> Lee C.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.