Sunday 15 February 2015

change asp.net request/response encoding for one single page -



change asp.net request/response encoding for one single page -

i have next settings in web.config (unfortunately)

<globalization fileencoding="windows-1252" requestencoding="windows-1252" responseencoding="windows-1252" />

if want alter 1 page's request encoding utf8, not utilize <%@ page requestencoding="utf-8" responseencoding="utf-8" %> according http://msdn.microsoft.com/en-us/library/39d1w2xf(v=vs.100).aspx because these properties not exist.

if add together code page's code behind

protected sub page_init(byval sender object, byval e system.eventargs) handles me.init me.request.contentencoding = encoding.utf8 end sub

to forcefulness utf8 request encoding, not seem work @ all. if alter web.config utilize <globalization requestencoding="utf-8" responseencoding="utf-8" /> works fine page. don't want alter setting globally.

anybody has suggestion?

you can utilize location section in web.config file set specific properties single page or folder. in case should add together configuration similar this:

<configuration> <system.web> <globalization fileencoding="windows-1252" requestencoding="windows-1252" responseencoding="windows-1252" /> </system.web> <location path="yourfile.aspx"> <system.web> <globalization requestencoding="utf-8" responseencoding="utf-8" /> </system.web> </location> <configuration>

asp.net encoding

No comments:

Post a Comment