I'm exploring the Rails caching in order to speedup the page loading of a website that is becoming very big passing the time.
Said this i'am done the simple steps to enable caching on my pages and it works very well.
Using caches_page :page_name
I have only one issue - I find a lot of unwanted characters in my page, it is regarding letters like "à" or " ' ", " ° ".
E.g. : instead of "'" i got "’"
this is related both for text inside the database and static text in the page.
What should be the cause of this wrong font rendering?
My fonts are included in the fonts directory and work very well in the non cached pages - they are google fonts (Roboto and RobotoCondensed).
I'm using heroku for production and I don't know if I have to change some production environment configuration to manage this.
I got no errors in console and no other messages.
SOLVED!
there was a missing line in my of the html layout file:
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
this set the correct character encode on all the pages
I'm developing an app in ASP.Net MVC4 and am having a strange issue with whitespace. I've developed plenty of MVC3 sites with Razor without this issue.
Here's my template cshtml file:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>HF - Content Management - #ViewBag.Title</title>
<link href="#Url.Content("~/content/bootstrap/bootstrap.min.css")" rel="stylesheet" />
#Styles.Render("~/bundles/css/hf-cms-logged-in")
</head>
<body>
#Html.Partial("Partials/NavBar")
<div class="container">#RenderBody()</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="#Url.Content("~/scripts/bootstrap/bootstrap.min.js")"></script>
#Scripts.Render("~/bundles/js/validation")
<script src="#Url.Content("~/scripts/hf-cms.js")"></script>
</body>
</html>
Note the line with the RenderBody() call - there's no extraneous whitespace here.
When I call an action, the rendered body is prepended with some whitespace which I can't see that I've added, and can't seem to get rid of. I call an action with no logic, it only returns the following view:
#{
ViewBag.Title = "Dashboard";
}
<h1>Dashboard</h1>
It's definitely using the correct template (specified in my _ViewStart.cshtml)
Viewing the page in Google Chrome, the source shows extra whitespace. See the image below:
A similar issue can be seen in IE10. This is obviously affecting the design. I've tried using Meleze.Web to strip out any extra whitespace, but whitespace still remains.
I'm at a loss with this one, as it's a relatively simple site so far, there's nothing funky going on yet, so I can't see where this whitespace is coming from.
Has anybody else seen this with MVC4 or Razor before?
Edit: I've tried removing all stylesheets and script files, the whitespace still exists.
After struggling with this for a while, I've found the solution.
There must have been a funny character in the root _ViewStart.cshtml file. I deleted the contents of the ViewStart file and retyped it, which solved the problem. This got me thinking that a strange character could be causing the issue.
Don't like answering my own question, but I hope this helps somebody else. In theory, this won't be an MVC4-specific issue, you could encounter the same problem in MVC3.
I encountered the same problem, and Steve's answer put me on the right track, that it might be an unusual character embedded in the file.
In my case, it turned out to be a duplicate Unicode Byte-Order Mark (0xEFBBBF) at the start of the file. It seems to have snuck in when I copied and pasted the file contents in from a Git Extensions diff view.
Incidentally, Visual Studio has a built-in Hex viewer. If you right-click on a file in the Solution Explorer and click "Open With..." you can select "Binary Editor".
I have been experiencing the same problem, and tried the approach you put forth, Steve. However, that didn't solve my problem. What I found was involved in causing the problem was the h2 tag at the top of my child page:
<h2>#ViewData("Title")</h2>
When I removed the wrapping tags, everything worked fine:
#ViewData
As a test, I took the styles for the h2 and placed them in their own class and then wrapped my page title content with a span:
<span class="pagetitle">#ViewData("Title")</span>
This worked fine, so is how I corrected the problem with my site. Though I don't know the true root cause, this did fix my problem, so perhaps it will help someone else out there.
I've just experienced a similar problem - in my case, one of the #using directives at the top of the view was causing an issue. I found the same thing in a couple of different views in my project.
One thing that helped me to locate the offending characters was pasting the whole view's contents into Notepad - it was immediately clear that the lines in question had somehow been encoded differently (they appeared smaller than the other lines, even in Notepad). Deleting the lines and rewriting them from scratch solved the issue, though I'm sadly none the wiser how I got into that position in the first place...
I have had the same issue and thanks to the clues here I was able to identify the problem.
After a lot of investigation I figured out that there was a Unicode character ‘zero width no-break space’ at the start of the page. This character is added to a page when it is saved/encoded as ‘UTF-8 with BOM’. I can only guess that the page was edited outside of visual studio, copied in from somewhere else, or maybe the page encoding was set incorrectly in VS. You stated in other answers you can see it by the looking at the once copied and pasted into notepad.
I faced the same problem, and I fixed it as follwoing:
- change column (Field) datatype in your database from nchar to nvarchar.
this is because nchar reserve fixed length, hence if your string is shorter than this length it will complete it with spaces.
I had a similar problem, but a much more obvious solution. I had an Html.Partial() inclusion in my <head> element with an ; after the method call. Which again is rendered in the body.
<head>
#await Html.PartialAsync("Test"); // The ";" is rendered in the body, remove it!
</head>
<body>
...
</body>
As title says. Story is, I've changed meta mark-up of my _Layout.cshtml page from:
<meta charset="utf-8" />
to
<meta content="text/html; charset=utf-8">
Effect? No Polish characters on page. Ok, let's revert the change. Effect? No Polish characters on page.
Btw it affects ONLY _Layout.cshtml, all other views show Polish letters properly. Proper letters are replaced by "Ĺ‚" characters.
Any ideas? Thought about changing browser, but it didn't work. Same stuff happens on different computer.
No other changes were made. Tried to revert project to older version from repository, didn't work.
Opened in notebook and saved again wit UTF-8 encoding set. Worked.
I'm noticing that in places where our site uses special characters on a webpage, such as ¡ or ¿ or even "special quotes" (like MS-word) it displays this funky � character
Is there something I can to do fix this? Is this a charset thing?
I know I could use html entities, such as
¡
But, I wanted to see if there was something else to address this since I notice some other sites don't need to use the special code.
Thanks
did you try to use the following meta tag?
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
I had a grails 1.1 app working where keyword and description meta tags were dynamically generated. There was a change in how that works in 1.2, but I cannot found good documentation. I've tried numerous ways to make it work. No matter what I do the resultant html gets something like
<meta name="keywords"/>" />
instead of the actual keywords. The extra tags there are not a typo on my part. So it also creates a bug in my rendered html.
In Grails 1.2, there's a performance optimized integration to Sitemesh. You can use the old implementation if you specify grails.views.gsp.sitemesh.preprocess = false in Config.groovy.
There are several issues in Grails JIRA related to meta tags :
http://jira.codehaus.org/browse/GRAILS-5605
http://jira.codehaus.org/browse/GRAILS-5598
http://jira.codehaus.org/browse/GRAILS-5696
Some of them will be fixed in Grails 1.2.1 .
I have had problems in 1.2 with meta tags dynamically generates and found that the problems happened when the quote was followed by a $. If I put a space between the quote and the $ it worked like
<meta name="keywords" value=" ${keywords}"/>
May or may not be your problem...