我有一个 asp.net mvc 网站,它向网站上的某些页面返回 JSON 结果。我还希望能够将结果返回到托管在其他网站上的 iframe。但是,如果请求来自另一个网站上的 iframe(我的意思是来自另一个域上托管的 iframe),我希望能够在 Controller 的操作中检测到这一点并相应地调整结果。是否有可能在操作中知道请求来自另一个域(或来自 iframe,无论哪种方式)?
非常感谢!我没有太多跨域工作的经验...
最佳答案
Is it possible to know in the action that the request is coming from another domain
来自另一个域 是 => 只需检查 Request.Url
属性。从 iframe,不,你不能。 HTTP 协议(protocol)中没有定义任何强制来自 iframe 的请求与正常请求无论如何不同的内容。
关于asp.net-mvc - 请求来自 iframe 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9845870/