How make Firefox see changes to .aspx page? - asp.net

I created an aspx page and viewed it in Firefox and it worked correctly, running the code. But when I make changes to the page (including deleting everything and serving up a blank page), Firefox continues to show the original compiled aspx page! How can I get it to see the new page?
I even added the following code, but it still loads the original page:
<script runat="server">
Sub Page_Load
Random rd = new Random();
Response.AddHeader("ETag", rd.Next(1111111, 9999999).ToString());
Response.AddHeader("Pragma", "no-cache");
Response.CacheControl = "no-cache";
Response.Cache.SetNoStore();
Response.Expires = -1;
End Sub
</script>
I even cleared Firefox's cache, but it still loads the original version!
EDIT: It appears the issue might be on the ASP.Net side. It's also not changing in Chrome. So, how do I force changes to an aspx file to force a recompiling?

I've had luck with the following code:
// Stop Caching in IE
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
// Stop Caching in Firefox
Response.Cache.SetNoStore();
Also, your browser may have already cached it prior to when you added the cache prevention code. If so, try hitting CTRL-SHIFT-R in Firefox to force a reload without hitting the cache and see if you still have a problem with Firefox storing cached copies of your page.

Since it appears the issue is not firefox related but something in the ASP.Net web server (since it happens in Chrome as well), I've asked a different question and will close this one.

Yet another way to reload and override cache CTRL + F5
It may also depend on how you are developing your ASP.Net application/site
re-compiling after making changes before viewing again?
If you are building a web application, you have to rebuild (In Visual Studio) your application to reflect any change(s) you made to server side code - this isn't an "ASP.Net issue" it's the norm. You can make changes to the HTML (client side) without re-building, but any server code change will need a rebuild (recompile the dll(s)).
The sample code you have above however, looks like in-line code - is all your code in-line - as in you don't have code behind files (i.e. foo.aspx.vb or foo.aspx.cs)?
All the above is based on local development - obviously if you are viewing your "production"/live site, then it goes without saying that you have to "push"/"publish"/upload/update, whatever local changes you made to it.

Related

Asp.Net output Caching not working

I'm trying to cache some of my ASP.Net pages.
I followed this tutorial and managed to make it work properly : http://msdn.microsoft.com/en-us/library/sfw2210t%28v=VS.90%29.aspx.
Now, when applying the exact same technic on my ASP.Net website, I have absolutely no cache whatsoever... When hitting F5 on my page, it simply reloads the same page again and again...
I added this on top of my aspx page :
<%# OutputCache Duration="15" VaryByParam="none"%>
And then on my Load method, basically writing the current time to check if it's updated or not, just like the above example... Unfortunately, the time changes everytime I hit F5...
What am I missing here ? Some configuration or ?
Thanks for your help !
I've found that our project used a framework that called the following code :
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
Response.Cache.SetNoStore();
That was the source of my issues...

asp.net multiview issue with Safari

I have a very simple page built in asp.net (.NET Framework 4) which has a multiview containing a few views that are displayed as a button is clicked - this seems to work fine on all browsers I have tested with on my local machine but as soon as I move it to the server, the active view doesn't change when the button is clicked when viewing the page with Safari.
I don't see any errors or warnings when debugging (or when viewing the page on another browser on the server). Interestingly, the page displays and works fine on the server if i view it with my iPhone(4S) but trying to browse it using Safari 5.1.2 installed on my PC is where I am seeing the problem.
The code that doesn't appear to be firing is as simple as below and fires on an asp button click:
MultiView1.ActiveViewIndex = 2
Has anyone encountered any similar issues as I haven't been able to find anything much online?
The page in question can be seen at the following URL - http://www.ddlgroup.eu/ArdbegSurvey/survey.aspx
I have check the page and what I think you need to do is to disable any possible cache on browser because the page name is not change from page to page and from post back to post back, and this maybe the problem. Add all this parameters on PageLoad and try again.
Response.Cache.SetExpires(DateTime.UtcNow.AddYears(-4));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetNoStore();
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0));
Response.Expires = 0;
Response.CacheControl = "no-cache";
Response.AppendHeader("Pragma", "no-cache");
In my safari same version is worked fine - some other error appear on the end of survey.
The issue seemed to stem from accessing the site using Safari through the main business proxy - I don't understand exactly how this could have been an issue but changing to use a different proxy seemed to solve the problem

ASP.NET Response Content

I have tested this in IIS 6.1, IE 7, ASP.NET 3.5 SP1.
I have a file download in a method in my aspx codebehind:
Response.ContentType = contentType;
Response.AppendHeader("Content-Disposition", contentDisposition);
Response.BinaryWrite(file);
This works great, but if I attempt to modify any of my sever side controls the changes do not take affect. I have isolated this down to the call to ContentType, this apparently whipes all pending changes to the Response stream when called? Does this sound familiar to anyone?
If the code takes an alternate branch and the call to download does not fire the markup is modified as expected.
Any suggestions on how I can fix this and have the page flush the attachment and update the UI in the same response stream?
This is specifically for updating the ValidationSummary, so I could tear into the JS on the PageRequestManager event complete as a last resort, but I'd prefer not to rely on JS for this.
Not sure what you're trying to do - are you trying to simultaneously serve a download file and an update to the HTML page they linked to it from? That's not how HTML works.
If you want to achieve this result then you'll basically have to render a meta redirect that goes to the file which is returned in the HTML, that way the page will load and then the download starts (Like you'll see on a lot of download sites).
As fyjham said, I don't really understand what you're trying to do. A few tips that might help:
Keep in mind that the Render phase, when the content from your markup and controls is generated, happens as almost the very last phase in your code behind (well after Page_Load)
Once you flush headers, you can't set them again
Controls can override some HTTP headers
You can't mix a file download and HTML markup in the same HTTP response

IE6 postback in asp.net

I have a page that contains a user control that is just a personalized dropdown list . I assign to each item the attribute onClick=__doPostBack('actrl',0).
when I click the page postback fine and I got the expected results. However in IE6 my page doesn't change to the new values loaded from the server.
The weird thing is that when I shift + click on the link The page reload fine with all changes.
I tried to disable caching on the page but no luck.
using all this code
Response.CacheControl = "no-cache"
Response.AddHeader("Pragma", "no-cache")
Response.Expires = -1
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Page.Response.Cache.SetExpires(DateTime.Now.AddDays(-30))
Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)
Page.Response.Cache.SetNoServerCaching()
Page.Response.Cache.SetNoStore()
Response.Cache.SetNoStore()
Also when I debug the application I can see that the generated html to be rendered is correct, but it is not rendered.
This problem happens only in IE6.
This is a known IE6 bug (#223) with magical HTTP get requests.
See the bug here:
http://webbugtrack.blogspot.com/2007/09/bug-223-magical-http-get-requests-in.html
It happens when an inline event handler causes a page change in IE6.
The problem is that IE6 is not reloading the page from the server (its just grabbing the cached copy), however on a form post IE6 SHOULD reload. Why are you adding the _doPostBack as an attribute, those should be autogenerated on any asp.net control that needs to post back.

Random Page_Load calls on back button in ASP.NET

I'm hoping someone has seen this before because I can't for the life of me find the problem.
I'm trying to do the old "fix the back button" thing in an application and I think i have a pretty decent approach, the problem is that it relies on the application not calling page_load when you hit back and instead loading the cached version of the page.
On about 60% of my pages that's exactly what happens. It loads the cached version and all is well. On the other 40% when i hit the back button page_load calls, forcing a refresh. For reference the call to page_load is NOT in a postback.
Even stranger is that this only occurs in IE (6 & 7). In firefox page_load never gets called.
I am using ASP.NET Ajax framework on both types of pages. Anyone seen anything like this before?
--Update--
After investigating a bit more I'm finding out that when i use the search to navigate from one page to another the application behaves differently for different pages. On the broken pages the page_load gets called twice, the search gets called twice and in fiddler that turns into 2 different redirect postbacks the second of which has no-cache set.
On the working page page_load and search only happen once and it immediately redirects.
That second Response.Redirect is causing the issue. Still not sure why that's happening though.
Check what the server is returning for the cache-control http header, then try setting Response.Cache.SetCacheability()/ use the output cache page directive on the pages and see if the server is saying that the pages should be cached.
if you are using ASP.NET AJAX why not using the History server control object?
replacing History, the back button will go to the link you want.
try this

Resources