asp.net cookieless session and app themes, is it possible to have css files referenced from url without session id?

464 Views Asked by At

I have a asp.net web application that uses cookieless sessions (i.e. session id is in the url, not in a cookie) and themes. Using themes, references to css files will be included in the HTML sent to the client with a url that includes the session id like:

http://website/(S(12344jkjl232343)/app_themes/folder/site.css

If the css references images using a path relative to the css location, those images will be retrieved via a URL that includes the session id as well.

Since the session id changes after every login, clients will always have to request the css file(s) from the server at least once at the beginning of the session and cannot use the local browser cache.

Is there a simple way to have asp.net insert the links to the resource files without session id, so that repeat visitors will be able to use their local browser cache?

Looking for a quick and simple/low risk way. That is, simpler (and creating a smaller re-test surface) than moving away from using themes in the first place, which would be the mid-term plan.

Thanks!

1

There are 1 best solutions below

1
On

So if you are using cookieless sessions, I am inferring that the users will always be in the same web site.

If they are in the same web site, you do not need to send the theme over http. Instead store the theme in a session (memory).

// store the selected theme
this.Session["theme"] = "/app_themes/folder/site.css";

or create a table and just store the there id

// store the selected theme
this.Session["Themeid"] = "1";