I working with a site which uses obfuscated ids to display the URL/route.
Instead of
controller/edit/23
it would show something like
/controller/edit/ftoGI8yFctjGPLYBl1ButA%3d%3d
I'm trying to redirect to the /edit route after a user successfully does a "create" on a form. In the controller I have:
return Json(new { responseText = "create_complete_redirect", url = Url.Action("Edit", "MyController", new { id = EncryptId(returnObj.ObjectId) }) });
EncryptId is a function that generates the obfuscated id. It works fine in many other places so that is not the issue.
The problem is when I receive the json data on the client side, the url comes out to:
/controller/edit/ftogi8yfctjgplybl1buta%253d%253d
All of the case sensitive parts of the encrypted Id are now forced to lower case. Is there a reason this is happening? The response on the network tab in Developer Tools shows that the data is coming down from the server as all lower case.
It seems like the problem is in the Url.Action call. If I put a breakpoint at at that part of the code in the controller, and run the EnctrypId function, it shows the correct string is generated.
If I try to run the whole Url.Action command in the controller I get an error
"Expression cannot contain anonymous types".
Any idea why the url.action parameter is not preserving the case?