How to set Response Header before Server.Transfer in Asp.Net?

后端 未结 3 831
陌清茗
陌清茗 2021-01-13 13:41

I have a page where based on certain conditions I am either doing a Response.Redirect or Server.Transfer. Now I want to add a header for both the cases. So I am doing the fo

3条回答
  •  失恋的感觉
    2021-01-13 14:03

    when you call Server.Transfer, the Response object of the current page will be replaced by the Response object of the target page (which is the Response that will actually be sent to the user). So, if you want to set this specific header attribute, you must do it on the target page.

    If it's conditional, maybe you can use a HttpContext.Items property, that is set on the first page and read on the second.

    Regards

提交回复
热议问题