I have the following example page structure:
If I call Server.Execute("Script.aspx")
from Webpage.aspx, how can I detect in Script.aspx that it was called from Webpage.aspx and not directly from a web browser?
I've tried checking the Referrer but this only seems to return domain and not the script.
I'm using ASP.NET Web Forms on .NET 3.5
Since Server.Execute runs the new page with the same context as the original page, all the properties of Request should still reflect the original request to Webpage.aspx (except for CurrentExecutionFilePath, which hopefully contains "/Script.aspx"). Request.Path should contain "/Webpage.aspx", while Request.Url will give the full Uri object if you need to see the domain or querystring.
You can also add values to Context.Items before calling Server.Execute and read them in Script.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With