dqg17080 2014-01-25 12:15 采纳率: 0%
浏览 44

重定向消息Symfony

I am currently wondering why sometimes when redirecting in Symfony via $this->redirect($this->generateUrl()) a message is shown with "Redirecting to: myURL" and other times there is no message at all and it is immediately directed to the url without that message. I also tried the same redirect in different controller actions and in one action the ugly message was shown and in the other not. Any suggestions why this behaviour might occure and how to prevent it?

EDIT:

For further clearification on my scenario. I have a form flow with multiple steps and very time one step is submitted and is evaluated as valid, I redirect to the next step. I have this scenario twice in my application and in one scenario it just shows directly the next step of the form flow but in the other scenario it first shows the ugly "Redirecting to: URL" page which I cannot figure out why and is really annoying for the user experience.

  • 写回答

1条回答 默认 最新

  • doutingyou2198 2014-01-25 14:07
    关注

    This is how it should be done according to RFC2616:

    The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).

    Symfony works exactly like that. It sets a body for the RedirectResponse and later removes it if the request method was HEAD. So the request method should be HEAD if you don't want the text.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c