views:

348

answers:

2

My team and I are working on a portal applicaiton. When a user requests a page, we get a page object (contianing permissions, actual file to use and what not). We then do a Response.Redirect to "~/Default.aspx".

The crazy thing is that when the code to validate access and what not is called from a button click event from within an ajax update panel, response.redirect is pasting a "&f2" or a "/" into the url. So rather than http://localhost/Default.aspx, the webbrowser is being redirected to http://localhost/%f2Default.aspx, and is subsequently returning a 404 error.

HttpContext.Current.Response.Redirect("~/Default.aspx", false);

Anyone have an idea of why this would occur? And it only happens when the click event fires inside an update panel.

A: 

It sounds like it is escaping the URL. Can you call a method on the code that is generating the URL to decode it before output?

BrianLy
That was my first thought, but as listed in the original post . . . that is the redirect code . . it is not a redirect that has a "dynamic" url to it. It is hard coded.
andrewWinn
A: 

The solution is to set up the update panel like this:

<asp:UpdatePanel ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="ddlNewAddressCountry" EventName="SelectedIndexChanged" />
    <asp:AsyncPostBackTrigger ControlID="ddlAddressState" EventName="SelectedIndexChanged" />
    <asp:AsyncPostBackTrigger ControlID="ddlNewAddressCity" EventName="SelectedIndexChanged" />
    <asp:AsyncPostBackTrigger ControlID="ddlNewAddressPostalCode" EventName="SelectedIndexChanged" />
    <asp:PostBackTrigger ControlID="btnCustomerAddressEditCancel" />
  </Triggers>
...
 <td colspan="2">
                            <asp:Button ID="btnCustomerAddressEditSave" runat="server" OnClick="CustomerAddressEditSave_Click"
                                Text="Save" />
                            &nbsp;&nbsp;&nbsp;
                           <asp:Button ID="btnCustomerAddressEditCancel" runat="server" CausesValidation="false" OnClick="CustomerAddressEditCancel_Click"
                                Text="Cancel" />
                            &nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnCustomerAddressEditDelete" runat="server" OnClick="CustomerAddressEditDelete_Click" OnClientClick="return confirm('Are you sure you want to delete this record?');"
                                Text="Delete" />
                        </td>
                    </tr>
                </table>
        </ContentTemplate>
    </asp:UpdatePanel> 
andrewWinn