オブジェクトの作成後、オブジェクトが正しく作成されていても、マイページは詳細ページに進みません。続きASP.Net MVC 3 - 成功した作成後の詳細リダイレクト
は私のコードです:
Function Create(ByVal collection As FormCollection) As ActionResult
Dim _NieuweKlant As New Domain.Slave.Klant
Try
If ModelState.IsValid Then
TryUpdateModel(_NieuweKlant, collection)
_NieuweKlant.UpdatedON = Now
_NieuweKlant.LaatsteWijzigingGebruiker = Now
'_NieuweKlant.LaatsteActie = Now
KlantService.createKlant(_NieuweKlant)
KlantService.SaveKlant()
'check validstate
Return Details(_NieuweKlant.KlantID)
End If
Catch ex As System.Data.Entity.Validation.DbEntityValidationException
Dim Errors = ex.EntityValidationErrors.First
For Each propertyError In Errors.ValidationErrors
ModelState.AddModelError(propertyError.PropertyName, propertyError.ErrorMessage)
Next
Return View(_NieuweKlant)
Catch ex As System.Data.Entity.Infrastructure.DbUpdateException
Return View(_NieuweKlant)
Catch Ex As Exception
' Console.Out.Write("Bericht:" & vbCrLf & Ex.Message)
' Console.Out.Write("InnerException: " & vbCrLf & Ex.InnerException.ToString)
Return View()
End Try
End Function
私もすでにRedirectToActionを試してみましたが、デバッグ時に間違いがあるようには思えません。リダイレクトしたり、他のアクションに移動したりすることはありません。
例外がありますか?そうでない場合は、どのビューがレンダリングされていますか? – krolik
tryリターン詳細(_NieuweKlant.KlantId)の代わりにView( "Details"、_ NieuweKlant.KlantId)を試してください –