0

I have MapRoute on my C# MVC website like this :

 routes.MapRoute(
                name: "Default4",
                url: "{param1}/{param2}/{param3}/{param4}",
                defaults: new { controller = "Home", action = "Index" }
            );

and the URL that access will contain encoded value

$2a$10$InFyv7LT7RUa.IRfJcY/B.edpZsJcRtImQrODwN9lvb2pee0jJ/Bu

sample URL :

http://localhost:53610/ftth/wa/33747501/%242a%2410%24InFyv7LT7RUa.IRfJcY%2fB.edpZsJcRtImQrODwN9lvb2pee0jJ%2fBu

here's my controller code :

[HandleError]
public class HomeController: Controller {

    public ActionResult Index(string param1, string param2, string param3, string param4, string param5) {

      Response.StatusCode = 302;
      String userAgent;
      userAgent = Request.UserAgent;
      string typevalue = "";
      string value = "";

      param1 = string.IsNullOrEmpty(param1) ?
        "" :
        param1;
      param2 = string.IsNullOrEmpty(param2) ?
        "" :
        param2;
      param3 = string.IsNullOrEmpty(param3) ?
        "" :
        param3;
      param4 = string.IsNullOrEmpty(param4) ?
        "" :
        param4;
      param5 = string.IsNullOrEmpty(param5) ?
        "" :
        param5;

      if (param1 != "") {
        // do something
      }
    }

tried the setting with config not fix the problem. but the value could be in any path, is ther solution to handle this? because the code always get 404.

Sabilv
  • 602
  • 1
  • 15
  • 44
  • Can you add the controller/action declaration that should be hit when this URL is entered, please? – Jackdaw May 26 '23 at 09:48
  • @Jackdaw updated my question with controller code – Sabilv May 26 '23 at 09:52
  • Any parameters on the URL should be after a question mark. See : https://en.wikipedia.org/wiki/Query_string?force_isolation=true – jdweng May 26 '23 at 10:01
  • @Sabilv: See the following post: [Dots in URL causes 404 with ASP.NET mvc and IIS](https://stackoverflow.com/questions/11728846/dots-in-url-causes-404-with-asp-net-mvc-and-iis). An additional, pay attention that your URL has 6 section but your `MapRoute()` declaring 4 section. Therefore, by fixing this and using `-` instead of `.` in the URL is easing way to fix your problem. But if dots intended to use parameters as files name you should use solution in the referenced post. – Jackdaw May 26 '23 at 11:08
  • 1
    @Sabilv: I think solution for your case is described here: [https://stackoverflow.com/a/30548064/6630084](https://stackoverflow.com/a/30548064/6630084) – Jackdaw May 26 '23 at 11:15

0 Answers0