創建對象後,儘管對象已正確創建,但我的頁面不會繼續到詳細信息頁面。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
嘗試返回查看(「詳細信息」,_ NieuweKlant.KlantId)而不是返回詳細信息(_NieuweKlant.KlantId) –