Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent ASP.Net from sending a default charset?

I'm working on building some web pages for testing various vulnerability scenarios, but ASP.Net, or IIS, is doing too good a job of protecting me from myself.

One of the things I'm trying to do is return responses with various Content-Type headers, with and without charset declarations. The problem I that if I leave out the charset, then ASP.Net seems to add in utf-8 by default.

In my ASPX.cs code-behind, if I have Response.AddHeader("Content-Type", "text/html") or Page.ContentType = "test/html", I would expect to see the following header returned by the page:

Content-Type: text/html

Instead I get:

Content-Type: text/html; charset=utf-8

If I use Response.AddHeader("Content-Type", "text/html; charset=iso-8859-1") then I get the expected header:

Content-Type: text/html; charset=iso-8859-1

Is there a way to stop ASP.Net (IIS?) from appending charset=utf-8 to the header when I don't want it?

I'm using ASP.Net 4.0 and IIS 7.5.

like image 561
Andrew Cooper Avatar asked Oct 23 '13 15:10

Andrew Cooper


1 Answers

Try this:

Response.Charset = "";
like image 140
IT63 Avatar answered Oct 18 '22 09:10

IT63