erfahrener Neuling - Mo 15.07.19 15:30
Titel: RedirectToAction bringt Laufzeitfehler
Hallo Leute,
bei einem Asp-MVC5-Projekt ist mir heute etwas komisches passiert. Und zwar rufe ich aus einer Action heraus eine andere Action per RedirectToAction auf. Funktioniert ja sonst auch.
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| [HttpPost] public ActionResult Action1(MeinModel model) { ... return RedirectToAction(nameof(Action2), "MeinController", new { param1 = model.Value1, param2 = Model.Value2 }); }
[HttpPost] public ActionResult Action2(string param1, int param2) { ... } |
In diesem Fall wird die Action2 gar nicht erreicht. Er lädt eine Weile und bringt dann eine Fehlerseite
Hat jemand ne Idee woran es liegen könnte?
MfG.
Julian
erfahrener Neuling - Mo 15.07.19 16:02
Also Fehlerlogging gab es hier noch nicht.
Ich habe den Fehler selbst gefunden: Anscheinend kann man nicht ohne weiteres
auf eine Post-Methode Redirecten [
https://stackoverflow.com/a/129361].
Nimmt man das HttpPost-Attribut bei Action2 weg, funktioniert es.
C#-Quelltext
1: 2: 3: 4: 5:
| [HttpGet] public ActionResult Action2(string param1, int param2) { ... } |