0
I’ve already researched it, I’ve spent two hours burning the dog but I couldn’t find a solution. Has anyone ever had that problem?
I have the following link:
http://localhost:49609/Manufacturer/Editarregistro/53/1/4/G/3/13
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
});
Man 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]
Man button to edit the record 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]
By clicking on button it presents the error:
I can’t decipher because damn, my controller is taking the value of vFAB_IN_CODIGO as null, and it is identified in the URL.
[EDITION]
Now I discovered that the problem occurs in the second ROUTE created, when I call the first custom ROUTE the system performs normally, but when executing another ROUTE with the same parameters the system displays the null parameter error.
///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
});
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:
When clicking normally calls to the edit ROUTE.
Now by clicking delete which calls the second route with the same parameters, but Action different from the error.
I’m doing it wrong?
[/EDITION]
Tried instead of getting
string vFab_In_Codigo
receiveint vFab_In_Codigo
. In the error message it says that it is not coming whole, maybe for some reason(supernatural) it is not converting int to string– Barbetta
In fact he is int I put it as a string to check the value that was returning, but it always returns as null. [link]https://imgur.com/a/g34oyD6
– Alex Sandro Martins de Araujo
vFab_In_Codigo
isint
orint?
???– Leandro Angelo
"int", as it is a record edit button it has to pass the/ composed keys to find this record in the database.
– Alex Sandro Martins de Araujo
and you noticed that in the view you assign
item.Org_Tau_St_Codigo
forOrg_Tau_In_Codigo
, Is this difference in name right? I built your structure here and got no error.– Leandro Angelo
Leandro, I verified that the problem occurs in the second route onwards. I edited the post with some new details that I detected.
– Alex Sandro Martins de Araujo
The two routes have the same number of parameters; how do you think MVC will be able to solve which is which?
– Marcelo Shiniti Uchimura
Marcelo thinking about what you said, I reached another conclusion/solution. I will post the {GATO} that was made to work this.
– Alex Sandro Martins de Araujo