gefüllt Ich habe eine Methode in einem Controller:Optional Parameter immer
public ActionResult SendNotification(Guid? id=null, SendNotification notification =null)
Es reagiert auf /Apps/SendNotification/{guid}?{SendNotification properties}
SendNotification ist ein Modell mit mehreren String-Eigenschaften.
Mein Problem ist, dass SendNotification NIE null ist. Egal, wie ich die Aktion nenne. .NET scheint immer ein Objekt von SendNotification zu instanziieren (mit allen Feldern null).
Ich habe sogar mit der System.Web.Http.FromUri
und System.Web.Http.FromBody
getestet und es tut das immer noch.
Irgendwelche Ideen?
Hinweis: Dies ist nicht WebApi. Dies ist eine normale MVC.
Mein Projekt haben nur die Standardroute:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
was ist Ihre Route? –
Hinzugefügt oben. Hinweis: In meinem ursprünglichen Beitrag gab es einen Fehler in der URL meiner Anfrage (ich habe es behoben). – rufo