CSS not updated during debugging ASP.NET MVC application - asp.net-mvc

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"

Related

Bootstrap Glyphicons not visibile after refreshing IE

If I start the Project with Visual Studio(2013) and choose HTTPS the first time the application starts I see the glyphicons but not if I refresh the page.
If I do the same with HTTP then I dont have this Problem.
In my web.Config I don't use Cache and I also checked the Font Folder everything seems OK.
I saw many similar question on stackoverflow like this link
or this one but nothing helped.

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.

Uploadify not clickable in JQuery UI's Dialog and Firefox 17

This is a really weird issue. I've first read the answer from Maayan Glikser on this question which looked similar : Uploadify inside Jquery UI Dialog => Chrome & Opera bugs
It didn't work at all. Let me explain my problem.
I have 3 different Uplodify (Flash version) controls on my website (not on the same pages), only one of them doesn't work and it's the one that is inside a JQuery UI Dialog. Basically, the button is visible but not clickable. The problem occurs only for this particular control, the others behave normally.
So I tried adjusting the z-index inside the javascript, it didn't change anything. Then I tried adding manually (through firebug's "edit html" feature) a <br /> at the beginning of the container generated by uploadify and bam, the button became clickable
I then tried adding the <br /> on page load with $("#fmuploader").prepend('<br />') and nothing happened, the line break was added but the button wasn't clickable. When I added manually a blank space it became clickable again.
I believe there is some kind of paint event that gets triggered when you manually edit the page from firebug which makes the button suddenly become clickable, but I'm really wondering if I can make it finally work as intended without asking all my firefox-using visitors to install firebug :)
It is really hard to explain so I have setup a small test page at this address : deleted (edit: the test page is now offline on the production environment and is no longer reachable)
This reproduces exactly the problem I have.
Load the page, click the link to open the popup, open firebug, find the uploader's container <div id="fmuploader" class="uploadify" style="height: 30px; width: 120px;"> and just add a blank space after the opening tag. The button becomes clickable.
The problem occurs on Firefox 17 with no add-ons except firebug and Flash 11. The problem does not occur on IE 7/8/9 and Chrome on the same machine.
Update: I tested it with Firefox 15 and wasn't able to reproduce the bug.
I had a similar issue, but found that updating Firebug to version 1.11 sorted it.
It was only seemed to be the issue in verstion 1.10.
Looks like a change in the Firefox 17 security model means that minified version of jQuery breaks when using Firebug. Plenty of jQuery based stuff has stopped working for me in Firefox 17 unless I disable Firebug.
https://blog.mozilla.org/addons/2012/08/20/exposing-objects-to-content-safely/
https://developer.mozilla.org/en-US/docs/XPConnect_wrappers

External stylesheet content gets included on page somehow

I've run into a weird issue with a site running ASP.NET MVC on IIS7.
Whenever I do a page refresh (F5), the external stylesheet content gets "injected" into the page itself, instead of the tag pointing to the css file. Example:
<head><link type="text/css" rel="stylesheet" href="external.css" /></head>
Renders as:
<head><style type="text/css">body{ color: #000; }</style></head>
Locally, there is no issue at all, only when it is uploaded to the server.
If I do a hard refresh (Ctrl + F5), it renders as it should, but subsequent requests will not.
I'm inexperienced with IIS7, so I don't know if this issue could be caused by it.
Any help would be appreciated.
Turns out an improperly closed script tag was wrecking havoc with the page.
After fixing it the page renders normally.
Well, this is a weird issue. I don't know if IIS7 has a setting, or a handler that would cause this.
Try using a tool like Fiddler or Live HTTP Headers to verify the external CSS file is actually not being requested at all.

Rails Partial rendering results in a blank page?

I'm stuck with a bug at the moment which is puzzling me. I have a
layout containing some HTML and a partial (for the navigation) - there
is nothing else there other than the yield.
If the nav is included as a partial I get nothing returned to the
browser at all (blank page) but everything else appears normal
If I remove the partial the page works fine
If I put the nav code directly in the template it works fine
if I replace the nav code in the partial with a simple string, I get
a blank page again.
Does anyone have any ideas as to what the problem could be, or know how
I might debug it?
Found the issue, the partial was in the layouts folder, instead of the
relevant controller views folder.
However, Rails was throwing a ActionView::MissingTemplate Exception
which was only visible via the debugger which is probably a bug.
First off, check the log file to see if you're getting an error message somewhere. If that doesn't help follow these steps:
Make a copy of your template & partial, linked as the original
Test that they exhibit the problem
Start removing things from them until you have the simplest possible case that still exhibits the problem (your string in the partial test is a step in this direction)
If you don't figure it out in that process, come back and edit your question to include the code for the simplified case
I have had this error on a number of occasions. The problem has always been solved by changing something in the offending template or one of it's partials (in my latest case, I added a blank line into the source between a </div> and a <div>, which was in a partial invoked by the template; changing the template itself had no effect). The really odd thing is that the problem rarely occurs when I actually change a template, but usually when I change something related (e.g. edit an image displayed in the page or the CSS relating to the page). While the problem is often related to a partial, the entire page is blank, not just the portion provided by the partial.
BTW, restarting the web server (in this case Unicorn) does not fix the problem. Running Ruby 1.9.3, Rails 3.1.3. Using SASS and Unicorn.
UPDATE: Just determined that Rails is returning a 304-not modified, based upon the "If-none-match" header sent by my browser (which in turn was based upon the ETAG of the previous page). However, in the meantime, the browser cleared the window. So, presumably, something in what Rails sent caused the browser to clear the window.

Resources