Search code examples
asp.net-mvcencryptionhtml.beginform

Using ViewBag in as route value in Html.BeginForm converts ViewBag value to lower case


I am trying to pass an encrypted string through BeginForm's route collection by delivering it in a ViewBag like:

@using (Html.BeginForm("Go", "Process", new { id = ViewBag.Id }, FormMethod.Post, new { @class = "seperate-sections fill-up form-horizontal", enctype = "multipart/form-data" }))

ViewBag.Id is a dynamically encrypted string such as: g9IPGGXm4jw=

Unfortunately when it reaches to my controller via form submit; it comes in lower case like : g9ipggxm4jw= which causes an exception on decryption process.

Do someone have an idea about where it becomes lower case?


Solution

  • I found my answer. The problem was routing!

    My routing has force lowercase definition as routes.LowercaseUrls = true;

    So it was automatically converting the url to lowercase and my encryption was getting broken!