Response.WriteFile("mymenu.aspx") Bug? - asp.net

I'm using Response.WriteFile("mymenu.aspx") to write a plain text file out to an area in a MasterPage. Unfortunately it's also printing out an unknown character represented by the square character. The contents of the menu file are as followings:
<ul>
<li>Accounts</li>
</ul>
The square character is what is causing my menu to display incorrectly, pushing it down about 20 pixels. I tested putting just the HTML in the master page instead of including the file and it works fine which mean it must be down to the Response.WriteFile function. I don't suppose anyone else has encountered this problem?
EDIT: I tried the following as well, just to really make sure I wasn't doing anything stupid and that the file didn't contain anything dodgy.
<%
Dim tw As New System.IO.StreamReader(Server.MapPath("menu.aspx"))
For Each s As String In tw.ReadToEnd
Response.Write(s)
Next
%>
It worked. But that still doesn't explain Response.WriteFile behaviour.

Have a look at your text file in an editor that will show all characters including carriage returns, line feeds etc. (Notepad++ is my choice). File may have an unusual eof marker or other encoding issue from the software that created the file.

This sounds like a character encoding issue. Is this file in the same encoding as the page your using it from?
Edit
Open the file up in a hex editor make sure there are no weird characters in there.

I tested your code and it rendered correctly for me.
I have seen ASP.NET alter incoming XML strings in WebMethods before. Save the text to a file on disk before you Response.Write it to compare. Check your CSS for your LI style.

Related

HTML entities are not displayed properly

I'm building a website with Wordpress, but sometimes (I don't know why) the html entities declared in my php files are displayed as a � (a black diamond with a white question mark). My charset attribute is already set to UTF-8 (as shown in the picure below). It could be a problem of the text editor (I'm currently using the built-in editor of Aruba)... How can I make sure that the encoding is right?
Try copying your code files into notepad++ and make sure that the encoding is actually set to UTF-8 without BOM.

Symfony2 renders template with blank line at top

My template starts with <!DOCTYPE html> on the first line, but for some reason when I view source on the page that's rendered, it starts on line 2.
This isn't a big deal in HTML, but I'm trying to render some XML and I'm running into the same issue, except XML isn't forgiving like HTML and must start on the first line.
EDIT
Thank you for the comments! I am a fairly new developer and was not aware of the BOM. That being said, I use PhpStorm, and you can just right click on a folder, then click 'Remove BOM', which I have done.
After doing that I ran this terminal command I found someone post grep -rl $'\xEF\xBB\xBF' that outputs files in the directory that have the BOM character. There were a few files listed, and I've fixed them all except /vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php. I've tried removing the BOM with PhpStorm, and haven't had any luck, so I opened the file with VIM and ran set nobomb like I found here: How do I remove  from the beginning of a file?, but it still comes out in the listing of the grep command above.
I faced the same issue, but because I closed my PHP file with "?>" and added some blank lines after. After removing the "?>", problem has been solved.
In this case nothing related to BOM directly (I was in UTF-8).
If this can help other people who find this post with the same issue than me.
See post : php: empty line from nowhere

Alfresco webscript text fromat line break

I created an alfresco webscript and output file as xxx.get.text.ftl file.
In the output file(xxx.get.text.ftl), I am trying to create text version of newsletter. But I am not able to get text lines with line break.
if I put
AAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBB
I am getting as
AAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBB
Any Idea what could be the reason?
EDIT:
in my case i have page, template-instance,template and region. It turns out that when I call web script that fill the region it displays as text.But if I call full url like "www.xxx.com/news/my-news" it includes other components like template, page etc. and it turns the output to html. Because output for template or page is hard coded to text/html in surf.
If is text try to add
\n
at the end of line
Whitespace and especially new-line handling is always an issue for template languages because it is not clear whether the remove the new line after a closing template-tag or not. See the freemarker documentation for discussion: http://freemarker.org/docs/dgui_misc_whitespace.html
I think you just have to add an extra newline.

Special char added to css (​) where did this come from?

I was doing a bunch of search-replace operations in notepad++ to effectively minify my css - mostly removing whitespace/tabs etc...) This ended up breaking much of my css.
Apparently a strange character (​) was inserted all over the place) Using notepad++ in UTF-8 without BOM, I cannot see these, but they appeared in a view-source.
I was able to remove these by doing a search replace in ANSI encoding, but my question is, what is this character, and why might it have appeared?
The string “​” is the UTF-8 encoded form of ZWSP when misinterpreted as windows-1252 encoded data. (Checked this using a nice UTF-8 decoder.) This explains why you don’t see it in Notepad++ in UTF-8 mode; ZWSP (zero-width space) is an invisible character with no width.
Apparently browsers are interpreting the style sheet as windows-1252 encoded. Saving the file with BOM might help, since then browsers would probably guess the encoding better. The real fix is to make sure (in a server-dependent manner) that the server sends appropriate Content-Type header for the CSS file.
But if this is the only non-Ascii character in your CSS file, it does not matter in practice, after you have removed the offending data.
I don’t know of any simple way to make Notepad++ insert ZWSP (you could of course use general character insertion utilities in the system), so it’s a bit of mystery where it came from. Perhaps via copy and paste from somewhere.
Using the web developer plug in or ext in Firefox you can see the problem character in the css document.
In Visual Studio all I could see was:
}
.t
Web developer showed an unwanted hidden character, an "a" with a caret on top:
}
â.t
The utf encoder link above revealed this
} (the encoded character for ampersand)
.t
and this
but simply fix the problem by deleting and retyping.

seam-gen and flex

I have integrated seam and flex with FlamingoDS
I got html file from mxml file and I stored it in WebContent folder it's fine
then I want to create link named as 'Plan' in menu.xhtml
My aim is to get that html file when i clicked on this button I don't know what to do for that
so, I have created some test.xhtml in that top element is the
for the template attribute this element I have given the template.html
and I used
then for 'Plan' link I gave the view="/test.xhtml"
It's fine when I clicked on that link I am getting the test.seam file which includes our html file but this html file is coming in some fixed area with scroll bars only eventhough there is a lot of space to fit
Please help...... me
First of all, it is very difficult to read your post. Please format it more readable.
Secondly, we can only guess what's wrong when we cannot see any code. But my hunch is that you are using s:decorate that includes some formating you are not aware of. This comes in standard seam-gen. Try removing that s:decorate stuff or point to another style you wish to use.

Resources