0

I have something like in asp.net core (I am using asp.net core c# using razor):

@Html.ActionLink("Edit", "EditEmployee","Employee", new { id = item.id})

this item.id is base64string which will decode in middle layer and it has slash('/') character in encoded string so action is not able to understand it and action parameter is null.

my question is how i can send this item.id to my action as it is base64string containing slash('/').

this is my map route in startup.cs:

routes.MapRoute(
       name: "EditEmployee",
       template: "{controller=Employee}/{action=EditEmployee}/{id?}");

This is my action which i need to call... but sue to double slash parameter is getting null.

    [HttpGet]
    [ActionName("EditEmployee")]

    public async Task<IActionResult> EditEmployee(string id)
    {
        if (!string.IsNullOrEmpty(id))
        {   
            var result = await _accountAction.GetEditEmployee(id);

            if (result.Item1)
            {
                return View(result.Item2);
            }

        }
        return RedirectToAction(nameof(ListEmployee));
    }
Ajay Sharma
  • 31
  • 1
  • 6
  • How about this? https://stackoverflow.com/questions/44920875/url-encode-and-decode-in-asp-net-core – Nimrod Dolev Dec 11 '18 at 16:49
  • encryption is working fine but my controller is not accepting this multi slash data as parameter. – Ajay Sharma Dec 13 '18 at 18:17
  • What I meant was why not use `WebUtility.UrlDecode`, changing your cshtml line to this - `@Html.ActionLink("Edit", "EditEmployee","Employee", new { id = System.Net.WebUtility.UrlDecode(item.id) })` – Nimrod Dolev Dec 14 '18 at 14:40

1 Answers1

0

I would simply remove the '/', '=' and '+' symbols from the string before saving it.

kjwdamme
  • 289
  • 4
  • 13
  • it is not possible because these special char appear at random position and it is encrypted data which is required to send to Business Layer – Ajay Sharma Dec 13 '18 at 18:16
  • Oh sorry, i did not realize it was encrypted data.You could check out Base58 – kjwdamme Dec 14 '18 at 10:15