开发者

Asp.net Response.Redirect Error

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 subsequent开发者_开发问答ly 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.


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?


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> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜