I’m having a problem with ASP.net redirection.
The Copy() method below is called from a javascript button in a grid with ajax and it works fine. It redirects to the Create action of the controller.
<AcceptVerbs(HttpVerbs.Post)> _
Sub Copy(ByVal noDemande As Integer)
Response.Redirect("/DemandeDeMontage/Create/" & noDemande)
End Sub
The Create action is a page that lets me edit the fields before saving them to the database. When an Id is passed, the fields will be pre-filled with another record’s info (copied info).
<AcceptVerbs(HttpVerbs.Get)> _
Function Create(Optional ByVal id As Integer? = Nothing) As ActionResult
If (id Is Nothing) Then
Dim dmd As New DEMND_MONTG
Return View("Edit", dmd)
Else
Dim dmd As ODCT0124_DEMND_MONTG = _dmdMontRep.getDmdById(id)
dmd.CO_STAT = ModuleCommon.Status.AwaitingSave
Return View("Edit", dmd)
End If
End Function
There are no errors in the code above.
When debugging, everything seems to work. The Copy action is called, then Create, and then I can step through the HTML code of the Edit page without any errors.
However, the page will not change! It’s like I’m not redirected at all. The edit page is not shown and I’m stuck on the page displaying the grid with all records I can copy.
Can someone explain why the edit page is not shown? Is there something really obvious I am not seeing?
That was a silly error on my part.
The
Copyaction was called viaAJAX, but I forgot to specify what to do with thehtmlreturned from the action.I’m using
window.location = "/DemandeDeMontage/Copy/" + idnow instead.