how to control request encoding outside of code in .net?

I am having issues with my requests being encoded differently in my prod environment vs dev.

in dev the request from my mvc app to my rest service is coming in as
dev – ?name=Hörberg
and in prod it is being encoded like this
Prod – ?name=H%25u00f6rberg

the code is the same so I am thinking it may be a configuration somewhere. I couldn’t find anything in the machine config. Maybe there is an environment variable for this?

both of my web.configs have this in them

<globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />

i am on .net v4.0, mvc5

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think this is URL encoded,try to use:
var decodedName = HttpUtility.UrlDecode(name)

Method 2

I believe this has to do with system settings, rather than any encoding/decoding. Validate the regional settings in both dev and prod environment. If you want prod to behave like dev, then make the settings same as dev in prod environment.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x