asp.net-mvc - 请求来自 iframe 吗?

标签 asp.net-mvc asp.net-mvc-3 http iframe cross-domain

我有一个 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/

相关文章:

asp.net - 将字符串传递到MVC4中的局部 View

javascript - chrome中的JS文件永远不会被缓存

ajax - 如何使用 Ajax 做出确认问题?

php - Google Closure Compiler 和 multipart/form-data 不工作

multithreading - 使用多线程,用C语言搭建一个简单的HTTP服务器

c# - MVC4 RenderViewToString 不尊重移动 View

asp.net-mvc - 在NHaml中指定标签属性时出错

c# - FluentValidation 可以处理嵌套集合吗?

asp.net-mvc - 使用 Nuget 更新 FluentValidation 后 NinjectValidatorFactory 出现错误

asp.net-mvc - MVC3 部署依赖问题