Post/Redirect/Get in Webkit causes a full page reload - asp.net-mvc

It seems that in Webkit-based browsers (Chrome and Safari) when a Post/Redirect/Get is performed on the server, the entire page (html + images + css, etc.) is redownloaded. It appears the same as if you reloaded the page.
There's been a question (and somewhat of a solution) posted in the Google Chrome Help: http://www.google.com/support/forum/p/Chrome/thread?tid=72bf3773f7e66d68&hl=en
Does anyone have a more elegant way of doing this? I'm working with ASP.NET MVC and would prefer to not write a custom Redirect result that returns Javascript or the actual page based on the UserAgent.
Should I just hope and wait that Webkit will change its behavior?

This is a bug. The only "workaround" I've seen untill now is to use a Refresh header instead of a Location header to do the redirecting. This is far from ideal.
Bug 38690 - Submitting a POST that leads to a server redirect causes all cached items to redownload
Also, this question is a duplicate of "Full page reload on Post/Redirect/Get ignoring cache control".

Try setting Cache-Control: public header.

Related

iOS Safari loads a wrong page

I've met a very strange bug when tried to open my web site http://akr-congress2016.ru/ in iOS Safari. Please see the screenshot below.
It seems like some elements are loaded from a completely other web site. The new site is a copy of the old one, but layout files (I'm using Phalcon) are changed. There is no link to the old web site at the page.
Also I've noticed doubled logo, it seems like a rendering bug.
When I refresh the page it is loaded normally.
I'm weird what might make Safari to load some fragments of the page from completely another domain.
The screenshot
Try to remove cache from browser. Or maybe it's just an issue of DNS. In that case you just need to wait untill DNS will get updated.

Sudden CSS styling issue only on Safari on iPhone

Trying to help troubleshoot an issue with a charity's web site and it appears that the site's CSS is only partially loading when viewed on Safari. A short link to the site is http://bit.ly/1znipeN
I've used the W3C CSS validator on the child theme CSS and it validated ok, less a couple of warnings. The odd thing is that the site appeared to be working fine until today. I wonder whether it could be a temporary issue in a 3rd party resource, such as JSQuery or similar that is causing Safari not to render correctly? It works fine in Chrome for example.
Is there any way of debugging it to try and find the cause?
If you haven't done so yet clear cache in Safari and Chrome and reload to check if the error is possibly now gone or visible in multiple browsers.
If you are using versioning such as git:
Undo all changes that have been made today (and maybe also yesterday) and test again. If the site works now on Safari, take the changes back in one by one and test which one breaks the layout.
If you use a preprocessor such as Sass, compare the size of yesterday's CSS file to the current one. If it is smaller there might be an error in rendering the file.
Hope one of these helps.
Ah interesting, so these lines we added to .htaccess were the cause for the site not to render correctly in Safari, Firefox and a few others (worked fine in Chrome).
<filesMatch "\.(js|css)$">
Header set Content-Encoding x-deflate
# Header set Content-Encoding compress
# Header set Content-Encoding x-gzip
</filesMatch>

Safari ignoring/removing anchors (or "hashtags") when clicking hyperlinks?

I need to point one page to another and then scroll to a particular section. In Chrome and Firefox, using an URL like www.example.com#section1 does the trick. (#section1 can be an anchor or an element's id).
However, in Safari, the hash disappears when I click the link.
Why is this happening? Is it possible to do it on Safari? If not, how can I get around this problem?
When using hyperlinks that point to inside sections on other pages you must remember to add a slash (/) before the hashtag for cross browser compatibility.
Eg: www.example.com/#item-1
doing www.example.com#item-1 isn't accepted by all browsers (apparently by Chrome and Firefox it is)
Case: I have parameters after '#' like url#myParam=123, when I changed params like
url#myParam=789 Safari sometimes loaded previous page based on myParam=123,
although in Address bar it showed myParam=789
Solution : Use url?#myParam=123, then Safari will everytime load new page.
Using '?' before '#' solved my problem.
I had a related problem with Safari (on iPhone/iOS) seemingly stripping off the hash/fragment when doing a:
var newHash = ...;
window.location.replace("#" + newHash);
The actually problem was a javascript error that only appeared on Safari. Since I could not easily assess a javascript console for the iPhone, I chose to download an old version of Window's Safari (related post, download).
Then, I could replicate the problem from the iPhone on my Window's desktop using the old version of Safari. At that point, I found a javascript tag had a missing ']'. This was a legitimate bug, but it was somehow ignored by Chrome, Firefox, and IE.
The window.location.replace() was not even being called, because the code was breaking out on the javascript error. So the problem wasn't that Safari was stripping the hashtag, even though it appeared that way from multi-browser testing.
I just experienced an issue like this. I was using a URL re-write in the asp.net web.config. With Safari, the hash and everything after was removed. After trying some of the things mentioned above I was still having problems. The issue for me was that this was all happening under HTTPS. Once I specified the full URL in the redirect and included the https:// scheme the redirect worked correctly and preserved the hash. Note this wasn't an issue with Chrome or Firefox.
For me it was the exact same issue like mrbinky3000 has stated above: The server mod-rewrite was killing the hash in safari.
The solution was to use a full absolute link like:
http://www.example.com/path/#item-1

CSS not updated during debugging ASP.NET MVC application

I am working on a test application based on ASP.NET MVC. I am new to CSS stuff so I am learning that as well.
I have created a master page called "new.master" and created a new css "new.css". I am calling the view from controller as:
return View ("About", "new");
What I am doing is that I am frequently updating the css and master page. So I run the application in debug mode frequently. After sometime I stop seeing the effect of changes in css. When I "view source" in chrome and check the css, it shows an old version.
When I change the name of both master page and css, I start to receive updated views but that works for sometime and then again I stop getting the CSS updates. Have you faced this problem? How can I fix it? (Its terribly annoying!)
Your browser is caching the css. If you force a refresh with F5 that should display any changes.
I think this may be a browser cache issue. In in IE and FF I usually do Ctrl + F5 or Ctrl + Refresh button. Also you can manually clear the cache. For IE you can use the IE Dev Toolbar and for Firefox there is Firebug with both you can clear the cache easily. Not sure about chrome, sorry.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
I found another case in which this can happen.
We started our application with just plain links to the CSS files, then switched to using bundling. We updated the old <link href="#Url.Content("~/somePath/someStyle.css")" rel="stylesheet" type="text/css" /> to #Styles.Render("~/Styles/bundles/someStyle").
We also use a few stylesheets which are only needed for some pages, and they have their own bundle. Now, for one of them, we forgot to change the link tag to the #Styles.Render statement.
The result was that this CSS got updated now and then (so we thought everything is OK; the style wasn't missing), but we could not influence when the update happens. When I started making changes to the file, I realized that nothing I do (emptying the cache, rebuilding the project, restarting Cassini) will trigger an update. The browser always got a 304 Not modified.
So, if you have these symptoms, check your links.
Please use Ctrl+F5 to refresh your browser.
F5 may give you the same page even if the content is changed, because it may load the page from cache. But Ctrl - F5 forces a cache refresh, and will guarantee that if the content is changed, you will get the new content.
hope this will help you
Thank you
go to chroom developer panel by right click inspect -> then go to Network tap -> tick the Disable cache checkbox (note: this should always be checked) -> Refresh the page by pressing F5.
this work for me, hope this help others who have this issue! :)
It's very possible that css is being cached in your browser, so simply clearch browser cache, it should help
This happened to me when I had a master view that would load partial views depending on which partial view the user wanted to see, but the answer from this page helped, https://forums.asp.net/t/1763494.aspx?applying+CSS+layouts+to+a+partial+view
CSS must be referenced in the of the Html document. As a
consequence you cannot include them in a partial view...because in
such case the css is included in the Html body. Please plce the style
sheet in head of the page that hosts the partial view.
I would have css links in my partial views and any modifications to the css files would never happen, even if I pressed Ctrl-F5 in the browser. I also tried clearing cache contents in the developer tools. I noticed by viewing the source stylesheets that the css files linked by the partial views were not changing, so the fix for me was to move the css links from the partial view to the main view where these partial views were to be held.
I had something similar happening to me.
Then suddenly noticed the bundle was added to the page:
#Styles.Render("/bundles/classifiedDetailCss")
instead of:
#Styles.Render("~/bundles/classifiedDetailCss")
Note the missing ~ character in the first example.
(The first example only worked after building the project, otherwise it would return a cached version even in debug mode.)
This can help solve this issues in both dev and production.
use asp-append-version="true"

Firefox Extension - Need a specific div to ignore xhtml errors (mismatched tag, etc)

My firefox extension loads content from a 3rd party site into an overlay panel. This content is user generated and sometimes will, for instance, have an image tag that does not close which causes a mismatched tag error to be thrown and the extension fails. Is there any way I can sandbox this content so that these kind of errors are not an issue? I was thinking maybe load the content into a blank iframed page.. but was wondering if there might be a cleaner solution.
Unfortunately, unless you're getting back XML, there is no XPCOM solution for parsing. Your best bet is what you suggested - placing the content in an iframe.
You can find some more discussion about the topic at: http://www.mozdev.org/pipermail/greasemonkey/2005-April/001255.html
Your guess about an iframe was correct, there's no better way to do it (as of Firefox 3.5): Parsing HTML From Chrome on MDC

Resources