I already researched, I spent 2 hours burning my skull but I did not find a solution. Has anyone ever had this problem?
I have the following link:
Controller -> Fabricante
Action -> EditarRegistro
Param01 ->53
Param02 ->1
Param03 ->4
...
Param05 -> 13.
My route is configured as follows:
///ROTAS PARA FABRICANTE
routes.MapRoute(
name: "EditarFabricante",
url: "{controller}/" +
"{action}/" +
"{org_tab_in_codigo}/" +
"{org_pad_in_Codigo}/" +
"{org_in_codigo}/" +
"{Org_Tau_In_Codigo}/" +
"{vFab_In_Codigo}/" +
"{Alf_In_codigo}",
defaults: new
{
controller = "Fabricante",
action = "EditarRegistro",
org_tab_in_codigo = UrlParameter.Optional,
org_pad_in_Codigo = UrlParameter.Optional,
org_in_codigo = UrlParameter.Optional,
Org_Tau_In_Codigo = UrlParameter.Optional,
vFab_In_Codigo = UrlParameter.Optional,
Alf_In_codigo = UrlParameter.Optional
});
My controller is configured:
[Route("EditarFabricante")]
public ActionResult EditarRegistro(int Org_Tab_In_Codigo,
int Org_Pad_In_Codigo,
int Org_In_Codigo,
string Org_Tau_In_Codigo,
string vFab_In_Codigo,
int Alf_In_Codigo)
{
ViewBag.NotView = ViewData.vNotView;
var appFabricante = new WebEstFabricanteAplicacao();
var webFabricante = appFabricante.ListarUmRegistrodaOrganizacao(Org_Tab_In_Codigo,
Org_Pad_In_Codigo,
Org_In_Codigo,
Org_Tau_In_Codigo,
int.Parse(vFab_In_Codigo.ToString()),
Alf_In_Codigo);
return View(webFabricante);
}
[EDIT]
My button to edit the registry is as follows:
<a href="@Url.RouteUrl("EditarFabricante",
new {action = "EditarRegistro",
org_tab_in_codigo = item.Org_Tab_In_Codigo,
org_pad_in_Codigo = item.Org_Pad_In_Codigo,
org_in_codigo = item.Org_In_Codigo,
Org_Tau_In_Codigo = item.Org_Tau_St_Codigo,
vFab_In_Codigo = item.Fab_In_Codigo,
Alf_In_codigo = item.Alf_In_Codigo})"
title="Editar Registro"
onclick="Loading();"
class="btn btn-primary">
<i class="fa fa-edit"></i>
</a>
[/ EDIT]
Clicking the button displays the error:
IcannotdecipherwhymycontrollerisgettingthevalueofvFAB_IN_CODIGOasnull,whichisidentifiedintheURL.
[EDITION]
NowIdiscoveredthattheproblemoccursinthesecondROUTEcreated,whenIcallthefirstcustomROUTEthesystemexecutesnormally,butwhenexecutinganotherROUTEwiththesameparametersthesystempresentsthenullparametererror.
///ROTASPARAFABRICANTEroutes.MapRoute(name:"EditarFabricante",
url: "{controller}/" +
"{action}/" +
"{org_tab_in_codigo}/" +
"{org_pad_in_Codigo}/" +
"{org_in_codigo}/" +
"{Org_Tau_In_Codigo}/" +
"{vFab_In_Codigo}/" +
"{Alf_In_codigo}",
defaults: new
{
controller = "Fabricante",
action = "EditarRegistro",
org_tab_in_codigo = UrlParameter.Optional,
org_pad_in_Codigo = UrlParameter.Optional,
org_in_codigo = UrlParameter.Optional,
Org_Tau_In_Codigo = UrlParameter.Optional,
vFab_In_Codigo = UrlParameter.Optional,
Alf_In_codigo = UrlParameter.Optional
});
routes.MapRoute(
name: "ExcluirFabricante",
url: "{controller}/{action}/{org_tab_in_codigo}/{org_pad_in_Codigo}/{org_in_codigo}/{Org_Tau_In_Codigo}/{vFab_In_Codigo}/{Alf_In_codigo}",
defaults: new
{
controller = "Fabricante",
action = "ExcluirRegistro",
org_tab_in_codigo = UrlParameter.Optional,
org_pad_in_Codigo = UrlParameter.Optional,
org_in_codigo = UrlParameter.Optional,
Org_Tau_In_Codigo = UrlParameter.Optional,
vFab_In_Codigo = UrlParameter.Optional,
Alf_In_codigo = UrlParameter.Optional
});
Running the first route:
ClickingusuallycallsfortheeditROUTE.
Nowwhenyouclickdeletethatcallsthesecondroutewiththesameparameters,butActionotherthantheerror.
Am I doing it wrong?
[/ EDITION]