开发者

How can I get the referer in an XBAP or ClickOnce Application?

开发者 https://www.devze.com 2023-03-28 17:33 出处:网络
I would like to put a Back button in my XBAP which takes the 开发者_JS百科user back to the page they launched the XBAP from, however I am not sure how to get the HTTP_REFERER from within the applicati

I would like to put a Back button in my XBAP which takes the 开发者_JS百科user back to the page they launched the XBAP from, however I am not sure how to get the HTTP_REFERER from within the application.

Does anyone know where it exists?


var h = BrowserInteropHelper.HostScript;
if (h != null)
{
    string s1 = h.location.href;
    if (!s1.StartsWith(sa1))
    {
        MessageBox.Show("Visit the original website at " + sa1 + " or disable referer control");
    }
}


If your XBAP is hosted in a frame in the browser, you can go back to the previous page by using interop.

var hostScript = BrowserInteropHelper.HostScript;
if (hostScript != null)
    hostScript.History.Back();

You cannot, however, retrieve the url of the previous page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号