0

I use HttpUtility.UrlEncode to encode my URL and email it as a part of an email, it works fine but when I want to get this URL and process it on my controller it has been encoded automatically.

As an example "g30EjT%2b" is a part of my URL

 public ActionResult MyController(string url)
     {
          //"g30EjT%2b" has been decoded to "g30EjT+b"
          //I mean "%2" converted to "+" automatically

       return view();  
     } 

How can I prevent it?

motevalizadeh
  • 5,244
  • 14
  • 61
  • 108
  • 1
    Please read https://stackoverflow.com/questions/26180572/url-parameter-encoding-in-mvc-net – EzLo Jan 07 '19 at 10:29
  • 2
    This feels like a XY Problem - https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem . **Why** do you want to disable the automatic url encoding? What issue does it present for you? – mjwills Jan 07 '19 at 10:30
  • @mjwills thanks for your answer, you mean if i encode my url and process it without decoding nothing will happened? and it's ok? – motevalizadeh Jan 07 '19 at 10:35
  • No, I am asking **why** you want it **not** be url decoded automatically? That is a very odd request. Thus, I suspect there is a real problem **behind** your request. – mjwills Jan 07 '19 at 10:36
  • to prevent some injection attack via URL – motevalizadeh Jan 07 '19 at 10:39
  • What kind of injection attack are you worried about? I am struggling to see how not decoding the value protects you from any attacks... _To be clear, I can give you the answer to your specific question - but I am 99% sure your question doesn't make sense (i.e. is a XY Probem) - so I want to understand the context before I answer it for you._ – mjwills Jan 07 '19 at 10:42

0 Answers0