Showing posts with label pages. Show all posts
Showing posts with label pages. Show all posts

Thursday, March 29, 2012

set cache-control tp private to public

should cache-control be set to public or private on dynamic site. our
content doesnt change for 24hrs, but because results from search pages vary
so much, we cant cache the pages themselves.

what other header info should i explicetly setting in the asp.net page to
make sure that the site is cached as much as possible?

Show Headers from http://www.mls.ca

Request headers sent:

HEAD / HTTP/1.0
Host: www.mls.ca
Referer: http://www.web-caching.com/
User-Agent: ReadHeaders/0.01 (www.web-caching.com)
Accept: */*

Received redirect headers:

HTTP/1.0 302 Moved Temporarily
Server: Microsoft-IIS/5.0
Date: Thu, 19 Feb 2004 21:33:52 GMT
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Location: /map.aspx
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 126
X-Cache: MISS from www.mls.ca
Connection: closeHi sviau,

Thanks for posting in the community!
From your description, you have an ASP.NET site which will generate dynamic
pages to users such as a search system. And since the Search result are
contant, so you'd like to cache them,yes?
If there is anything I misunderstood, please feel free to let me know.

Based on my experience, for your situation that those page are dynamically
generated via the user's input or some certain params,yes? There are two
means you can take:
1. Using the serverside outputcache provided by the ASP.NET
The ASP.NET's output cache can cache a certain page's certain version on
the serveside's memory, the version can be determined via different ways,
for example, querystring, time period, or event custom controling it. Thus,
when the ASP.NET detect that a certain version of the same request is
cached before, it'll directly returned the reponse retrieved from server's
cache rather than generated it again. I'm sure this is very wonderful for
some search system which need to cache pages for different search
querystrings, do you think so? And here are some tech reference on ASP.NET
outputcache, you may have a view to see whether it helps you.

#Caching ASP.NET Pages
http://msdn.microsoft.com/library/e...outputcache.asp
?frame=true

#Caching Multiple Versions of a Page
http://msdn.microsoft.com/library/e...hingmultiplever
sionsofpageorcontroloutput.asp?frame=true

2. Using the user's client browser's cache ability.
In addition to ASP.NET's page cache ability, generally the client browser
will also cache a certain page on the clientside, we can set the http
header of the response. And here are also some tech articles on this:

#How to Modify the Cache-Control HTTP Header When You Use IIS
http://support.microsoft.com/defaul...kb;en-us;247404

#Client-Side Page Cache
http://developer.apple.com/document...cations/Backtra
ckingAndCache/chapter_6_section_2.html

#HTTP Caching in Mozilla
http://www.mozilla.org/projects/net...aching-faq.html

Please check out the above suggestions to see whether they help.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

yes im familiar with asp.net cahcing, and client cahcing; but the
question is:
is Cache-Control: private setting correct in the header? or should it be
set to public? what does this affect?

thanks
stephane

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Hi Stephane,

Thanks for your followup. As for the Cache-Control header you, it can be
set in ASP or ASP.NET via
Response.CacheControl = (Public | Private | no-cache) .
The difference between private and public is that if set as private, the
cache will only speicfy to only the client , if "public" not only the
client, the other proxys are also able to cache this response. So as for
your situation, the private (by default) is enought. And here is the
detailed reference in MSDN:

#Response.CacheControl
http://msdn.microsoft.com/library/e...esopcc.asp?fram
e=true

Also, here is the HTTP/1.1 Cache-Control directive reference:
#HTTP/1.1 Cache Control
http://www.eurecom.fr/~ross/CacheTutorial/tsld067.htm

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Hi Stephane,

Have you checked out the items in my last message? If you have any further
questions, please feel free to post here.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Monday, March 26, 2012

Set error level in Visual Studio 2005?

I have a website I'm working on in VS 2005. Now a lot of the pages were done in Dreamweaver, but all the HTML errors that popup in the error list are really peeing me off. These errors are irrelevant, I couldn't really care if Element 'html' is missing required attribute 'xmlns'.

How do I stop these errors from displaying? I only want serious errors, I can't seem to find how to do it in the options, and help doesnt offer any suggestions either.

ThanksLook for the page's TargetSchema property.
Is there not something I can set at the application level? I have like 300 pages in my project...
Best you can do: They are warnings, ignore them.
Thing is, the 'serious' errors will prevent the application from compiling anyways. You'll see them with the exclamation mark next to them.

set Expires tag for images?

Hi - I want to reduce the download time of various pages by setting the
'Expires' tag for various images to a future date (this will then stop the
browser from re-requesting these for each new session).

I'm hosting on a commercial service so I don't have direct access to IIS
configuration. Is there anyway I can control this from my server-side code?

Thanks,

Paul.Paul W wrote:

> Hi - I want to reduce the download time of various pages by setting
> the 'Expires' tag for various images to a future date (this will then
> stop the browser from re-requesting these for each new session).
> I'm hosting on a commercial service so I don't have direct access to
> IIS configuration. Is there anyway I can control this from my
> server-side code?

Not if the images are served directly by IIS. Your ISP should be able
to change the server configuration to allow for caching.

BTW, you should prefer Cache-Control: max-age over Expires.

Cheers,
--
http://www.joergjooss.de
mailto:news-reply@.joergjooss.de
Currently the images ARE directly served by IIS. Can you point me to how
else I could do this so I can set the "Cache-Control: max-age"? Thanks,

Paul.
----
"Joerg Jooss" <news-reply@.joergjooss.de> wrote in message
news:xn0e3b26b6h8ll002@.msnews.microsoft.com...
> Paul W wrote:
>> Hi - I want to reduce the download time of various pages by setting
>> the 'Expires' tag for various images to a future date (this will then
>> stop the browser from re-requesting these for each new session).
>>
>> I'm hosting on a commercial service so I don't have direct access to
>> IIS configuration. Is there anyway I can control this from my
>> server-side code?
> Not if the images are served directly by IIS. Your ISP should be able
> to change the server configuration to allow for caching.
> BTW, you should prefer Cache-Control: max-age over Expires.
> Cheers,
> --
> http://www.joergjooss.de
> mailto:news-reply@.joergjooss.de
Paul W wrote:

> Currently the images ARE directly served by IIS. Can you point me to
> how else I could do this so I can set the "Cache-Control: max-age"?
> Thanks,

You could implemment a HttpHandler that serves your images, but this is
really a waste of time. Ask your service provider to change your IIS
configuration.

Cheers,
--
http://www.joergjooss.de
mailto:news-reply@.joergjooss.de

Thursday, March 22, 2012

Set href for <link tag

I need to dynamically set the href attribute for the <link> tag at run time
for my pages. I thought I saw code using the asp:placeholder to give the
code-behind a place to update the html control with a specific href setting.
Any ideas?
ThanksThis sets technique sets the Title programmatically but you might be able to
rejig it to do a <link>
http://authors.aspalliance.com/kenc/faq5.aspx
"Robert Strickland" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
>I need to dynamically set the href attribute for the <link> tag at run time
> for my pages. I thought I saw code using the asp:placeholder to give the
> code-behind a place to update the html control with a specific href
> setting.
> Any ideas?
> Thanks
>
Hi,
Give the <link> tag id="lnk" (can be anything) and runat=server attributes.
From code-behind, use the Attributes property, like normal server-side
controls, to add attribute values:
lnk.Attributes.Add ("rel", "stylesheet")
lnk.Attributes.Add ("href", "primary.css")
HTH.
"Robert Strickland" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
I need to dynamically set the href attribute for the <link> tag at run time
for my pages. I thought I saw code using the asp:placeholder to give the
code-behind a place to update the html control with a specific href setting.
Any ideas?
Thanks
thanks
"Shiva" <shiva_sm@.online.excite.com> wrote in message
news:#SjXjlliEHA.356@.tk2msftngp13.phx.gbl...
> Hi,
> Give the <link> tag id="lnk" (can be anything) and runat=server
attributes.
> From code-behind, use the Attributes property, like normal server-side
> controls, to add attribute values:
> lnk.Attributes.Add ("rel", "stylesheet")
> lnk.Attributes.Add ("href", "primary.css")
> HTH.
> "Robert Strickland" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
> I need to dynamically set the href attribute for the <link> tag at run
time
> for my pages. I thought I saw code using the asp:placeholder to give the
> code-behind a place to update the html control with a specific href
setting.
> Any ideas?
> Thanks
>
>
Thanks
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:#TdPDLliEHA.636@.TK2MSFTNGP12.phx.gbl...
> This sets technique sets the Title programmatically but you might be able
to
> rejig it to do a <link>
> http://authors.aspalliance.com/kenc/faq5.aspx
> "Robert Strickland" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
time
>

Set href for <link tag

I need to dynamically set the href attribute for the <link> tag at run time
for my pages. I thought I saw code using the asp:placeholder to give the
code-behind a place to update the html control with a specific href setting.

Any ideas?

ThanksThis sets technique sets the Title programmatically but you might be able to
rejig it to do a <link
http://authors.aspalliance.com/kenc/faq5.aspx

"Robert Strickland" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
>I need to dynamically set the href attribute for the <link> tag at run time
> for my pages. I thought I saw code using the asp:placeholder to give the
> code-behind a place to update the html control with a specific href
> setting.
> Any ideas?
> Thanks
Hi,
Give the <link> tag id="lnk" (can be anything) and runat=server attributes.
From code-behind, use the Attributes property, like normal server-side
controls, to add attribute values:

lnk.Attributes.Add ("rel", "stylesheet")
lnk.Attributes.Add ("href", "primary.css")

HTH.

"Robert Strickland" <bstrickland@.comporium.net> wrote in message
news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
I need to dynamically set the href attribute for the <link> tag at run time
for my pages. I thought I saw code using the asp:placeholder to give the
code-behind a place to update the html control with a specific href setting.

Any ideas?

Thanks
Thanks

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:#TdPDLliEHA.636@.TK2MSFTNGP12.phx.gbl...
> This sets technique sets the Title programmatically but you might be able
to
> rejig it to do a <link>
> http://authors.aspalliance.com/kenc/faq5.aspx
> "Robert Strickland" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
> >I need to dynamically set the href attribute for the <link> tag at run
time
> > for my pages. I thought I saw code using the asp:placeholder to give the
> > code-behind a place to update the html control with a specific href
> > setting.
> > Any ideas?
> > Thanks
thanks

"Shiva" <shiva_sm@.online.excite.com> wrote in message
news:#SjXjlliEHA.356@.tk2msftngp13.phx.gbl...
> Hi,
> Give the <link> tag id="lnk" (can be anything) and runat=server
attributes.
> From code-behind, use the Attributes property, like normal server-side
> controls, to add attribute values:
> lnk.Attributes.Add ("rel", "stylesheet")
> lnk.Attributes.Add ("href", "primary.css")
> HTH.
> "Robert Strickland" <bstrickland@.comporium.net> wrote in message
> news:eoYrcOkiEHA.356@.tk2msftngp13.phx.gbl...
> I need to dynamically set the href attribute for the <link> tag at run
time
> for my pages. I thought I saw code using the asp:placeholder to give the
> code-behind a place to update the html control with a specific href
setting.
> Any ideas?
> Thanks

Tuesday, March 13, 2012

Set pages encoding in code

A user can set the encoding his browser uses (In IE: View > Encoding).
I will show the page in the language the user selected (English or Japanes).
I do not want to create a seperate page for each language.
On the forms is some UserControls, with say menu's which i build in C# code, and I set the text of menu items according to the selected language.
The body of the page will be text extracted from the database in either English or Japanese.
Can one (should one?) set the page encoding in your code? I've seen that on the older asp pages, the developer set it to one value (en-jpn or sth like that...don't have access to the code as i'm typing), even though the page can be displayed in different languages, what l but sometimes a user have to go and manually set the encoding in his browser for the text to display correctly. (note : *Sometimes*)
Any suggestions what course to follow here?
It seems that with Chinese characters, on don't have problems, but Japanese is a bummer on it's ownGoogle for ResponseEncoding in ASP.NET.

BUT, I don't think that's the way it was meant to be/work. Shouldn't you be checking the language settings of the browser instead? (Tools > Options > languages)

Set property in Code-Behind from .aspx page

Hello there,

I have a number of aspx pages that are all the same but with different data in them. These pages are created by a content management system, and also retrieve some Database content based on a unique SQL statement.
Here are two .asp example pages so you can see what I am getting at:
http://www.cntraveller.co.uk/guides/England/
http://www.cntraveller.co.uk/guides/USA/

There is going to be one .dll file for all of these pages but I need to alter the SQL statment depending on which page you are viewing, for example for the Engand page it would be something like:
"SELECT * from Counties where Country = 'GB'" and the USA;
"SELECT * from Counties where Country = 'USA'".

My problem is I want to set somewhere in the .aspx page a variable that can be used in the SELECT statment. I have tried defining a function in the .aspx page like:


<script language="C#" runat="server">
void SetLBCountry()
{
this.strLBCountry = "GB";
}
</script>

and calling it from my .dll like this:


public strLBCountry;
private void Page_Load(object sender, System.EventArgs e)
{
SetLBCountry();
}

but it does not recognise the function when I compile it.

Anyone have any idea as to what I can do?

Thanks in advance,
Dave Asbury.You're going the wrong way, essentially you want the base class (codebehind) to call a sub only defined in a derived class (aspx page). It doesn't work that way. Why can't you just do this from the codebehind class?
Can you not simply parse the Request.Url to see what contry they are viewing from and then use some sort of select statement to get the relevant query string.. This could all be done in teh Page_Load method of the .dll
Thanks for your reply,

This is a good idea, but editors can create new folders and pages using the content management system and I don't want to have to edit the .dll to add in a new "If Request.Url = "blah blah" then strSQL = "SELECT BLAH" type statement.

I can see that there probably going to be other situations that require a similar solution too that I haven't come accross yet.

What I really would like is to be able to set a number of parameters in the .aspx page (this is the page that is created in the content management system from a template) that can be passed into the .dll - just like a form element or a querystring BUT that is set in the page the first time you view it (if you see what I mean!).

Any ideas??
Thanks for your reply,

I need to do it this way as I have my codebehind base class all set up and running fine, but I need all the different countries to use this one .dll but they all need different SQL statements.

The .aspx files are created by editorial staff using a content management system that uses a template and merges this with the data they put in to create the .aspx file.

What I want is for one of the fields they enter to be the key that is used to retreive further data from the database at run time - exactly as if I passed in a querystring or a form element - BUT I want this parameter to be in the page all the time so that when the page is viewed it is picked up and used inside the .dll file.

Do you see what I mean?
Still not sure if I get you fully, but could you an asp:textbox control to the page, you could set its text field to the value that you want and then set it Visiblity to false so that it doesn't show up on the page? you could then get the value of the textbox in the code behind page.
Yes!

That is exactly what I want, now you point it out I feel stupid for not seeing it.
Thanks for the help and sorry for taking up your time.

Dave.