Encrypted string comes from 404 error in ASP.NET MVC

In ASP.NET MVC 5.1, I have an action that gets an encrypted string, for example:

Nf7JnWp / QXfA9MNd52RxKpWg =

But I get a 404 error due to the slash inside this line ...

I tried to encode a string using HttpUtility.UrlEncode and WebUtility.UrlEncode;

But I have the same problems. Does anyone know how to solve this?

Thanks,

Miguel

+4
source share
1 answer

You can create a workaround for this by setting your own route. Now I do not know what you called your controller or your action, so I will use common names.

routes.MapRoute(
    "SpecialControllerName",
    "CustomName/{*id}",
     new { controller = "CustomName", action = "CustomAction", id = UrlParameter.Optional }
);

public ActionResult Name(string id)
{
  //logic goes here

}

, , . , http://yourdomain.com/CustomName/Nf7JnWp/QXfA9MNd52RxKpWg=, Action CustomName CustomNameController.

, asp.net Framework , . Defaultroute , .

SO:

+2

Source: https://habr.com/ru/post/1531148/


All Articles