Autor Beitrag
erfahrener Neuling
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 233
Erhaltene Danke: 19

Win 7, Win 10
C#, ASP-MVC (VS 2017 Community), MS SQL, Firebird SQL
BeitragVerfasst: Mo 15.07.19 15:30 
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.
ausblenden 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
errorASP

Hat jemand ne Idee woran es liegen könnte?

MfG.
Julian
Einloggen, um Attachments anzusehen!
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mo 15.07.19 15:49 
Hast du denn bisher noch kein Fehler-Logging bei dir eingebaut? Dann s. z.B. Errors handling and logging in ASP.NET MVC oder Demystifying ASP.NET MVC 5 Error Pages and Error Logging.

Da steht ja etwas von einer weiteren Exception - evtl. schau auch mal mit der Ereignisanzeige ("event viewer") nach.

Für diesen Beitrag haben gedankt: erfahrener Neuling
erfahrener Neuling Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 233
Erhaltene Danke: 19

Win 7, Win 10
C#, ASP-MVC (VS 2017 Community), MS SQL, Firebird SQL
BeitragVerfasst: 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.

Nimmt man das HttpPost-Attribut bei Action2 weg, funktioniert es.
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
[HttpGet]
public ActionResult Action2(string param1, int param2)
{
    ...
}