Prevent Page From Being Cached When Using OutputCacheAttribute?

Nov 9, 2010

Is there a way to prevent a page from being cached based on some logic?

I want to cache anonymous access to a page, so I can set VaryByCustom="user" and have some magic in Global.asax's GetVaryByCustomString method. Ok. But I don't actually want to cache the page if the user's authenticated, only if it's not authenticated. Is there a way to specify this kind of thing?

The reason I want the data to not be added to the cache to begin with (instead of added with some random key) is that as the cache grows things get thrown out and I don't want the non-authenticated version to get thrown out.

View 2 Replies


Similar Messages:

C# - Prevent Scripts From Being Cached Programmatically?

Feb 21, 2011

I would like to ask if there is a way to prevent Firefox from caching scripts (.js files).

I have a project (ASP.Net Web App) with caching issue on firefox. When I first run the application (script is being cached on firefox) and modify the script and rerun the application, firefox is using the cached script instead of the updated one.

I'm using Firefox 3.6.13.

I already tried using HttpHeaders but it seems like firefox is ignoring my codes.

Here is my code:

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(false);
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
HttpContext.Current.Response.Cache.SetNoStore();

I tried placing this code at global.asax > Application_BeginRequest and at MasterPage.aspx.cs > Page_Load, but it isn't working.

View 3 Replies

How To Prevent The Credit Card Number Field Being Cached By The Browser

Apr 26, 2010

I have an input field on a webpage that contains a credit-card number. What is the best way of preventing the browser from caching this value?

Any solution needs to work on a large selection of browsers.

View 2 Replies

How To Prevent Web Service Results From Being Cached In Web Service?

Aug 23, 2010

In my ASP.NET app, I noticed that the results of any web service calls are cached. I don't want any results to be cached, how can I stop the browser from caching the results?Update:Here's the proxy code generated by calling the web service URL appending '/js', e.g. /mywebservice.asmx/js

var MyWebService=function() {
MyWebService.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
[code]...

View 4 Replies

Best Way To Initiate The Page Caching On The Server Side And Serve The Cached Page Upon?

Apr 19, 2010

I'm implementing Outputcache in my application and it works fine, but the first time always take a lot to load and the next following request will be faster...

I would like to know if there is a way to initiate the page caching on the server side and serve the cached page upon the very first request, rather than have it triggered by the user one first time.

View 1 Replies

Page Not Being Cached?

Nov 29, 2010

why all the resources in my page are being requested EVERY single time. E.g. my site.css returns the following headers (using fiddler):

HTTP/1.1 200 OK
Server: ASP.NET Development Server/9.0.0.0
Date: Mon, 29 Nov 2010 17:36:21 GMT
X-AspNet-Version: 2.0.50727
Content-Length: 9093
Cache-Control: public, max-age=2592000
Expires: Wed, 29 Dec 2010 17:36:21 GMT
Last-Modified: Mon, 08 Nov 2010 17:20:16 GMT
Content-Type: text/css
Connection: Close

But every time I hit refresh I see all the resources (css,js,images) getting re-requested. I have control over the headers returned for any and all of these resources, but I haven't figured it out yet.I have even debugged my ASP.NET app and the HttpModule is definitely being asked for the resources again.

EDIT:Ok, I removed must-revalidate, proxy-revalidate from the headers and that is getting me closer to where I want to be, now when I press back it still requests my css/js files when I press back.

View 2 Replies

Possible To Detect Whether An ASP.NET Page Is About To Be Cached

Apr 20, 2010

Is it possible to detect whether an ASP.NET Page is about to be cached and if so, how?The HttpCachePolicy object provides only set-methods. The VaryByParams name-value collection is useless if values other than "None" and "*" are set as it impossible to enumerate them and you can only access them by key

View 1 Replies

C# - Web Page Still Displaying Cached Versions

May 3, 2010

My web page is still displaying a previously cached versions of the page. I have this in the page_load event:

Response.Clear();
Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1;
Response.CacheControl = "no-cache";
Response.Cache.SetCacheability(HttpCacheability.NoCache);

I have this in the Page_Init:

protected void Page_Init(object Sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
}

View 2 Replies

.NET - Refreshing A Posted Page That Isn't Cached On IE

Mar 6, 2010

Lets say you have a page with headers that tell the browser not to cache.Also, this page has already been posted back to itself.Now you hit the refresh button and you click cancel on the IE modal box with the "previously submitted..." message.You get "Webpage has expired". This doesn't happen in FF or Chrome.Is there a way to prevent the "Webpage has expired" message in IE?Since the page isn't cached, I guess IE has nothing to render.But if the page isn't cached and FF and Chrome shows it, I guess they just show the page as previously shown?

View 1 Replies

C# Code - Page Is Cached On The Browser Or Not

Jul 16, 2010

"Firstly check if "default.aspx" page is cached on the browser or not; if yes then Response.Redirect("default1.aspx"); else Response.Redirect("default2.aspx")

View 5 Replies

Cached Page Class Updated And Rebuilt?

May 26, 2010

When is the cached Page class updated and rebuilt?

View 1 Replies

State Management :: Add The Cached TreeView Control To Page, Nothing Happens. No Errors No Nothing?

Mar 24, 2011

I Have a TreeView that I populate from a DataTable.Once it has been populated, I Cache the Treeview.If I try to add the cached TreeView control to my page, nothing happens. No errors no nothing.If I create an empty TreeView control on the page and do a "Do Until" loop and add each node to that empty TreeView, that works! but only once. The next time it loops, for some reasion the CachedTree.Nodes.Count = 0.I can't see what I'm doing wrong.

[Code]....

View 4 Replies

Page At One URL Using The Cached Page From Another URL?

Dec 1, 2010

I'm pretty new to ASP.NET and very new to the concept of caching.

Using MCMS 2002, I built a template.aspx page that receives a "person_id" query string and builds pages accordingly. Several different departments at the school where I work are using this template to display faculty biographies. This much is all working correctly.

The Problem

The problems start happening when I try caching the page. When a person visits person_id=16175 on one department's page, then visits the same numeric bio on a different department page, it loads the cached page instead of rebuilding it. The problem, then, is that it has all of the wrong department branding. For example:

[URL]

It's the same person_id, but the URLs are obviously different. It would be great if the template would recognize the different URLs and ignore the cache. I'm assuming that the problem lies in the fact that both pages are being built using the same aspx page on the backend. Here's the OutputCache bit from the aspx page:

<%@ OutputCache Duration="86400" Location="Server" VaryByParam="person_id; section" VaryByCustom="CMSPosting" VaryByHeader="Referer" %>

I assume I'm doing something wrong here. Hopefully it will be obvious to someone who knows that they're doing. If you need more info, don't hesitate to ask.

View 1 Replies

Web Forms :: Prevent Master Page From Loading Whenever Content Page Loads?

Mar 10, 2010

The problem with my web application is when ever i load the home page - The master page as well as content page loads ---This seems fine but when i navigate thorugh the website which have the same Master page but diffrent content page .... the master page loads again. What i want to do is ..I want to keep the master page intact and only the content page loads. How can I accomplish it..

View 3 Replies

Databinding - Prevent Page From Automatically Binding Data Controls On The Page?

Dec 6, 2010

How can I prevent ASP.NET page from automatically binding data controls on the page? I want to increase performance and I want to do binding of each data control based on my own order.

View 1 Replies

How To Prevent The Page To Load Elements In The Page Refresh ASP

Jun 22, 2010

I have a page that add Items to RadioButtonList with this code :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
RD.Read()
RBQ1.Items.Add(RD.GetString(3))
RBQ1.Items.Add(RD.GetString(4))
RBQ1.Items.Add(RD.GetString(5))

View 2 Replies

.net - How To Prevent Go To The Top Page

Mar 27, 2011

Possible Duplicate:scroll go to the top page how i can prevent go to the top page when post back page (asp.net)

View 1 Replies

Prevent Postback When Page Is Loading?

Oct 6, 2010

I am a problem with Postback event.

I have a web page (aspx) which takes longer time to load the page. If this page is loading and if user requests same page by clicking menu link again, it is considered as not postback and page starts loading again (as soon as it finished first page load).

I want to prevent this from happening. When page is loading and user requests same page again, it should not process those requests and should be neglected.

This aspx page is requested from menu (which is designed on seperate master page).

View 4 Replies

How To Prevent Multiple Users On A Page

Aug 28, 2010

What whould be the best way to prevent multiple users on a page?

For example if a user is at the page "Home.aspx", no other users should be allowed to go there.

I'm using asp.net on the server and the js-frameword jQuery on the client side.

View 4 Replies

C# - Prevent Page Refresh On Pressing F5?

Nov 19, 2010

I have Created form with Server Side control like button..and also have written event on that.. Now runtime after click on the button i have refreshed the page by pressing F5.Page_load is executing fine but button1_click() event also firing...So how can i stop this event execution in this scenario.

View 6 Replies

VS 2010 - How To Prevent Web Page Going To Top Left

Apr 1, 2012

I have web page in asp.net and it goes to top left in web browser in different resolutions (with pressing ctrl n scrolling mouse) and controls also comes out of tables n div.

View 3 Replies

Web Forms :: Prevent Reloading Page

Aug 14, 2013

I visited website that it loaded very slow so I press F5 to reload page for many time after 5 or 6 time site show error that you reload page many time and didn't show website I want do it for my site that if users reload page morethan 5 time in short period of time it show error...

View 1 Replies

AJAX :: How To Prevent Page From Posting Back

Jul 30, 2010

I found alot of thread about how to postback after close the modal popup.

But for me, the system has already did it for me.

How to prevent page from posting back?

here's my code

[Code]....

View 2 Replies

C# - How To Prevent Firing Of Last Event After Page Refresh

Oct 9, 2010

Every time I refresh the browser, my button's event handler fires again. How do you prevent this?

View 2 Replies

How To Prevent Ajax.BeginForm From Loading A New Page

Feb 25, 2010

I have an Ajax form with a single input and a button. On submit, the form should only post the entered value to an action method. My form is correctly posting to the User controller's Log method but when done, the page redirects to /User/Log.

How can I avoid this?

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved