IE6 postback in asp.net - 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.

Related

Including ASPX file on a page via AJAX - viewstate error on post back only with IE

I have an ASP.Net web app which has a page with various GridViews shown in Jquery tabs. This works fine in Firefox and Chrome but the page is slow to render in IE. So I thought instead of loading all the gridviews at once, i'll just load them as and when the user clicks on a tab.
So I have set up a new aspx page which accepts parameters of what to show. This all works fine in all browsers and the page is now nice and fast in IE.
However, IE has come to bite me again, because as soon as the page hits a postback it generates this exception:
The state information is invalid for this page and might be corrupted.
From what I can understand this is because the GridView control that is loaded via AJAX has to be inside a <form> tag with runat="server" and this is changing the viewstate of the overall page. So when it postbacks the original page it seems to have lost its viewstate.
I then tried to turn off the viewstate in the aspx being included. Via EnableViewState="false" but this still doesnt work.
I'm confused how Chrome and Firefox are ok, but only IE is getting the ViewState error. Is there anything else I can do to ensure the sub-page does not alter the ViewState in IE?
Perhaps if ASP.Net didnt detect the browser as being IE, it wouldnt do whatever it is doing to break the page?
Set the enableEventValidation attribute in the web.config file for the asp.net application to false.
If using IIS6, make sure IIS compression is turned off.
If is possible, add OnClientClick event to button, that cause the postback, and call a function that removing added controls via ajax.
In the end, after lots of research I don't think what I was trying to do is possible.
As a work around I opted to insert an iFrame within the jQuery tabs, and then load the gridview in that. This then doesnt upset the viewstate of the parent page.

How make Firefox see changes to .aspx page?

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.

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

How to refresh page when hitting back button on browser (IE,Chrome,Firefox Safari)?

Most browsers reload the page from cache and do not perform a round trip server refresh.
I added Response.AppendHeader("Cache-Control", "no-store") on Page_Load but not working for Chrome, Firefox, Safari.
How to refresh page when hitting back button on browser (IE,Chrome,Firefox Safari) ?
This would be for your c# code I'm assuming.
These are my suggestions in order of most suggested to least.
Response.Cache.SetNoStore();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.AppendHeader("pragma","no-cache");
Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
It's probably a bad idea to force this behavior because the user is expecting to see what they saw before, not a refreshed view. If that's the behavior of Chrome/Firefox/Safari then presumably the users desire this behavior because they chose that browser. If they want a refreshed view, they can refresh on their own.
That said, I often see this done with Javascript in the browser. You can hook into page load events and manually refresh if you see the page being loaded a second time. But if the client uses noscript, or otherwise doesn't support Javascript, then you're out of luck. Also, be careful to reload correctly so that users don't get taken to a new page every time they click Back and get stuck in a battle of fast-clicking reflexes.

Chrome Back button page refresh - ASP.net

I have an ASP.net application (c#).
When a user is on a specific page, they click a link on this page that takes them to a child page, displaying the product details.
If the user clicks the browser back button, I need the parent page to be refreshed to its initial state. ie all text boxes that had data typed need to be blank, any hidden fields reset etc. Basically i need a CTRL-F5 when a user clicks back.
Disabling the back button is not an option.
I need this only on certain pages.
In IE and Firefox i can get this working without an issue. But with chrome the textboxes still contain their values as do the hidden fields. If I hit CTRL-F5 in Chrome, the page is correctly reset to its initial state.
This is the code I have tried.
<%# OutputCache Location="None" VaryByParam="None" %>
and this:
Response.Buffer = true;
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(false);
Response.Cache.SetNoStore();
and this:
Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
I have also tried a variety of these in different combination, but with no success.
thanks
When the browser's back button is pressed, the INPUT fields are not reset automatically by the browser. Instead, the browser retains the user's input, making it easier for users to go back and make a change to the input.
You cannot solve this server-side, because the browser bypasses the cache for this. Instead, you can use the autocomplete="off" HTML attribute on the input fields to prevent them from being retained by the browser.
You can also manually reset the form using JavaScript:
document.getElementById("form1").reset();
These two lines solved the Chrome problem for me:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
And I use this optional line to tell the browser not to create a history entry for each request of the same page:
Response.Cache.SetAllowResponseInBrowserHistory(true);
Sources:
Most popular answer in this post
Optional line
The 'brute force' solution would be to put some javascript on the page that on page load sets the data to some known state. So it finds all the elements and sets the data based on an array of data or json object. On the initial request, since everything is defaulted anyways, the setting doesn't make a difference. On a back button request, since the javascript still has to be run, it resets all the values, regardless of browser.
I don't believe you can force a browser to function in the way you describe though, as it's up to each browser how they want to implement a back button - chrome just does it differently.
You can also put the autocomplete="off" on the form tag instead of every input field.

Resources