Is there a way to get the parent URL from an Ifram

2019-01-12 06:21发布

I'm running an c# .net app in an iframe of an asp page on an older site. Accessing the Asp page's session information is somewhat difficult, so I'd like to make my .net app simply verify that it's being called from an approved page, or else immediately halt.

Is there a way for a page to find out the url of it's parent document?

标签: html iframe
4条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-01-12 06:36

Request.UrlReferrer.... to get the URL

NameValueCollection qs = HttpUtility.ParseQueryString(Request.UrlReferrer.Query);... to digest query string

查看更多
干净又极端
3楼-- · 2019-01-12 06:49
parent.location.href
查看更多
劫难
4楼-- · 2019-01-12 06:50
top.location.href

But that will only work if both pages (the iframe and the main page) are being served from the same domain.

查看更多
登录 后发表回答