How to detect if an aspx page was called from Server.Execute?

前端 未结 6 1422
醉梦人生
醉梦人生 2021-01-13 13:38

I have the following example page structure:

  • Webpage.aspx
  • Script.aspx

If I call Server.Execute(\"Script.aspx\") from Webpa

6条回答
  •  余生分开走
    2021-01-13 14:11

    Assuming you don't have any IHttpHandler funniness, you can check if HttpContext.PreviousHandler is not null. However, since there is a million (well, several) reasons that PreviousHandler could be set, I'd go with stevemegson's recommendation of using HttpContext.Items before calling Server.Execute.

提交回复
热议问题