Remove specification from page output via web.config

Our pages are currently being rendered using the Unicode specification.

I found one way to remove this by adding the following to my OnInit homepage.

 protected override void OnInit(EventArgs e) { base.OnInit(e); Response.ContentEncoding = new System.Text.UTF8Encoding(false); } 

Where false is passed to the constructor UTF8Encoding disables the specification.

This works fine, but I would rather set it in web.config rather than relying on the fact that it is in the OnInit hierarchy on any given page.

globalization element has a responseEncoding attribute that takes a string representation of valid encoding. eg.

 <globalization responseEncoding="utf-8" ... /> 

Is there a way to represent "utf-8 without specification" as a string that can be used as the value for responseEncoding in the web.config file?

+4
source share
1 answer

The BOM or byte order mark is sometimes quite annoying. Visual Studio does not modify the file if you did not save it (as Hans said).

And here is the solution to your problem: if you want to save the file with other encodings, select save as and continue the save button in the file dialog box and select "Save with encoding". Or, if you want to completely get rid of this setting, just open the “File” menu and select “Additional saving options”, and there you should select “UTF-8 without a signature” (and this also answered your last question :). Yes, "UTF-8 without a signature" is the same as without a specification.

+1
source

All Articles