【问题标题】:Why is my response.redirect() not working properly?为什么我的 response.redirect() 不能正常工作?
【发布时间】:2011-10-05 09:37:41
【问题描述】:

这个问题涉及到两个 aspx 页面。在一种形式中,我正在收集实体并将其绑定到会话变量中,然后单击按钮,我试图使用 response.redirect("") 方法进入另一个 aspx 页面。但是,问题是它给了我一个带有奇怪 URl 的错误消息。

让我给你看我写的代码

 formSaleMoneyReceiptEntity = ViewFormSaleMoneyReceipt_DAO.GetMoneyReceiptByFormSL(formSl);
            Session["MoneyReceipt"] = formSaleMoneyReceiptEntity;
            Response.Redirect("~/Reports/MoneyRepeiptFormReport.aspx",false);

我正在使用本地主机,而我得到的 URl 是

http://www.google-feed.net/results.php?q=localhost5808 StudentManagement FormSaleMoneyReceipt aspx &cx=002904446094441487865%3Ate-nlsbrcdy&cof=FORID%3A10&ie=UTF-8&said=&do=search&empty=0&from=2&CID=1

为什么会这样?我没有任何想法。请帮帮我。

【问题讨论】:

  • 试试~/MoneyRepeiptFormReport.aspx
  • 会不会是因为您在 MoneyRepeiptFormReport 中拼错了 Receipt?
  • 我读了大约 20 次试图找出错误,但每次都错过了拼写错误。哦!
  • Thnx,为了您的快速响应,这是我的代码中的拼写错误,现在它在更正输入的错误后可以正常工作。

标签: c# asp.net response.redirect


【解决方案1】:

看起来传递给浏览器的 URL 不存在,因此您将重定向到 Google 搜索页面。

~/Reports/MoneyReceiptFormReport.aspx吗?

用于调试这种情况的好工具是Fiddler。它充当您的 Web 服务器和浏览器之间的代理,并跟踪发出的请求和响应。浏览器有重新格式化错误消息的习惯,Fiddler 会准确地向您显示发送到服务器的内容以及返回的内容。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-06
    • 1970-01-01
    • 2020-09-19
    相关资源
    最近更新 更多