mardi 28 janvier 2020

How can you make call a page without showing parameters on the URL using C# MVC?

I am trying to modify a project so that the routes, and the parameters do not show in the URL, when you access them through an <a> element.

This is the code on the View:

@Html.ActionLink("Edit", "EditSchedule", new { id = item.OID, iorDapa = item.IOR_HORARIO }) |
@Html.ActionLink("Delete", "DeleteSchedule", new { id = item.OID, iorDapa = item.IOR_HORARIO })

I've tried to change the Action Link for a RouteLink, by calling this

 routes.MapRoute(
      name: "EditSchedule",
      url: "{controller}/{action}/{oid}_{iorDapa}",
      defaults: new { controller = "Users", action = "Index", oid = UrlParameter.Optional, iorDapa = UrlParameter.Optional }
 );

However, that didn't work, given that it keeps making a link element with an established URL, so I assume that something else is needed, perhaps some method I don't know to make a call to the api?

And... From here on I tried many things, but none seem to work.

From other projects I worked with (JS), I remember that the router called an API, which in turn called a controller file, and that controller did the logic to then call the view.

However, with this C# project I cannot get the program to call the WebApiConfig file, or the RouteConfig without actually showing the parameters on the URL.

I'm sorry If I have explained myself a tad bad, I'm a bit lost in this!




Aucun commentaire:

Enregistrer un commentaire