2
votes

*

I have this error with my action. Error My Controller

    [Authorize(Roles = ApplicationRoles.PAINELCHAMADA_EDITAR)]
    public ViewResultBase Editar(int IdEmpresa, int id)
    {
      var model = this.Service.Get(IdEmpresa, id);
      return base.PartialView(model);
    }

    [HttpPost]
    [Authorize(Roles = ApplicationRoles.PAINELCHAMADA_EDITAR)]
    public ActionResult Editar(PainelChamada item)
    {
      if (this.ModelState.IsValid)
      {
        try
        {
          this.Service.Update(item, this.GetFieldsToUpdate());
          return RedirectToAction("Index");
        }
        catch (ValidationException exception)
        {
          base.AddValidationErrors(exception);
          return base.View(item);
        }
      }
      else
      {
        return base.View(item);
      }
    }

View @model PainelChamada @{ this.ViewBag.Title = PainelChamadaResource.Titulo; this.ViewBag.SubTitle = Geral.Editar;
} @using (Html.BeginForm( this.DefaultActionEdit, "PainelChamada", "POST")) //new AjaxOptions //{ // InsertionMode = InsertionMode.Replace, // HttpMethod = "POST", // UpdateTargetId = "content" //})) { @Html.ValidationSummary() @Html.HiddenFor(i => i.Id)

    <input type="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="Alterar" />
} what might be happening? I try create routes in GlobalAsax, but no have success.

*

2
Try setting a break point on public ViewResultBase Editar(int IdEmpresa, int id). Is IdEmpresa null?alex

2 Answers

1
votes

It means that somebody sends a request to Editar action and doesn't specify value for IdEmpresa argument.

If you want to avoid this exception you could mark IdEmpresa and id arguments as optional in the route map and make them nullable in your method:

  public ViewResultBase Editar(int? IdEmpresa, int? id)

But in this case you will have to invalidate those values in your action.

This behavior is very common to web crawlers. Once, I had the same issue so I logged all the IPs that issued those requests - all of them were done by Google web crawlers. So in my case, I just ignored those exceptions

0
votes

It'd be good to see the available route mappings and the actual URL but you're probably passing no value for either or both parameters of your Editar action method. As both parameters it accepts are non-nullable ints (and I assume you have not made any of them optional in your corresponding route mapping) you get the above exception.