Home Dashboard Directory Help
Search

Server.transfer to another aspx-page fails in Ajax UpdatePanel by KumiteMan


Status: 

Closed
 as By Design Help for as By Design


3
0
Sign in
to vote
Type: Bug
ID: 373773
Opened: 10/8/2008 6:34:45 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

We have a big web-app (C#) with 250+ aspx-pages. It contains a complex navigation system (from aspx-page to aspx-page) which is based on Server.Transfer.

We are now trying to implement Ajax in the app. But we got into problems because Server.Transfer does not work from a control in an UpdatePanel. We have many aspx-pages with heavy datagrids that we hoped could be "Ajaxified", but these grids uses linkbuttons with "Server.Transfer" to navigate to another aspx-page. This doesn't work. So our Ajax-project stops!

I have read a lot about the problem, but cannot find any solution. Response.Redirect DOES NOT NOT work for us!

I have attached a simple working project that shows the problem.

When will a fix to this problem be available?


Regards from
ISV sertified partner 1250554

Details
Sign in to post a comment.
Posted by Jamie Clayton on 11/26/2008 at 9:47 PM
I've got a similar problem with a simple ajax page + Logon Control. In the Login1_LoggedIn event both Server.Transfer and Response.Redirect cause exceptions and ScriptManager.IsInAsyncPostBack = false.
I've had to supress the exception in the page event with the following code.

    Private Sub UserLogon_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Error
        ' LL:     Further work to suppress the error caused by the Server.transfer method + Ajax toolkit code.
        If Server.GetLastError.Message.Contains("Cannot redirect after HTTP headers have been sent.") Then
            Server.ClearError()
        End If

Fairly annoying feature of Ajax.
    End Sub
Posted by David A Nelson on 10/23/2008 at 7:42 AM
Response.Redirect exists for exactly this purpose, and it is the appropriate solution to this problem. I am not sure why you expect UpdatePanel to include a mechanism for redirecting based on Server.Transfer when that mechanism already exists in Response.Redirect. Can you explain why Response.Redirect doesn't work for you?
Posted by KumiteMan on 10/22/2008 at 11:22 PM
My example is a simplification of the problem! If you read my explanation you can see the orginal problem:
We use DataGrids for displaying data. An aspx-page with a DataGrid is at typical candidate for Ajax, so you can do paging in the DataGrid mutch faster and smoother. BUT: Some of the columns are LinkButtons you can click on to be transfred to another aspx-page. In our application this HAS TO BE DONE withe a Server.Transfer, not Response.Redirect!!!! This fails as you explained!

I hoped it should by possible for the UpdatePanel-mechanism to parse and understand that the retured HTML is a completely new page, and instead of just updating the panel, a Get to the new page is performed. This would actually solve our problem, and it would be tolerable to do the extra Get to the new page.

What is your opinion of my solution?
Posted by KumiteMan on 10/22/2008 at 11:22 PM
My example is a simplification of the problem! If you read my explanation you can see the orginal problem:
We use DataGrids for displaying data. An aspx-page with a DataGrid is at typical candidate for Ajax, so you can do paging in the DataGrid mutch faster and smoother. BUT: Some of the columns are LinkButtons you can click on to be transfred to another aspx-page. In our application this HAS TO BE DONE withe a Server.Transfer, not Response.Redirect!!!! This fails as you explained!

I hoped it should by possible for the UpdatePanel-mechanism to parse and understand that the retured HTML is a completely new page, and instead of just updating the panel, a Get to the new page is performed. This would actually solve our problem, and it would be tolerable to do the extra Get to the new page.

What is your opinion of my solution?
Posted by Microsoft on 10/22/2008 at 10:36 PM
Hi KumiteMan2,

Server.Transfer does not actually make sense within an update panel. With an update panel, only a portion of the existing page changes. A Server.Transfer causes an entirely new page to process in place of the current one, which is obviously not what the update panel was supposed to be updating. It doesnt work because the server is responding with a completely new set of HTML for the new page. There is no way to reload an entire set of HTML on the client without actually navigating to a new page. Redirect works in an UpdatePanel because it is possible to navigate to a new page on the client in response to that event. With a transfer, there is nothing to navigate to, the HTML is simply in the response.

You can tell if you are in an async postback with ScriptManager.IsInAsyncPostBack. You should check this flag, and use a Redirect if it is true, otherwise you can use Server.Transfer.

Posted by InfinitiesLoop on 10/22/2008 at 12:13 AM
Server.Transfer does not actually make sense within an update panel. With an update panel, only a portion of the existing page changes. A Server.Transfer causes an entirely new page to process in place of the current one, which is obviously not what the update panel was supposed to be updating. It doesnt work because the server is responding with a completely new set of HTML for the new page. There is no way to reload an entire set of HTML on the client without actually navigating to a new page. Redirect works in an UpdatePanel because it is possible to navigate to a new page on the client in response to that event. With a transfer, there is nothing to navigate to, the HTML is simply in the response.



You can tell if you are in an async postback with ScriptManager.IsInAsyncPostBack. You should check this flag, and use a Redirect if it is true, otherwise you can use Server.Transfer.
Posted by Microsoft on 10/8/2008 at 11:30 PM
We were able to reproduce the issue you are seeing. We are escalating this bug to the product unit who works on that specific feature area. The product team will review this issue and make a decision on whether they will fix it or not for the next release
Sign in to post a workaround.