dimanche 10 janvier 2016

Avoid Index form Url with string parameter in mvc3

I have a controler action like this

    [HttpGet]
    public ActionResult Index(string Id)
    {
    }

So actual call is like Report/Index/{string_param_value}

I want to avoid Index from this like Report/{string_param_value} and for that i did following change in Global.asax.cs

   routes.MapRoute(
      "Report_WithoutIndex",
      "Report/{Id}",
      new { controller = "Report", action = "Index" }
  );

But this one is not calling the Index action I tried this one then

routes.MapRoute(
            name: "Index",
            url: "{controller}/{id}",
            defaults: new { action = "Index" },
            constraints: new { action = "Index" }               
        );

And this one works for me But after this all other Actions are broken

SO what is the correct work around for making a call to Report controller wuthout mentioning Index in url

Aucun commentaire:

Enregistrer un commentaire