How to get referral site URL? - c#

I have posted my site URL on Facebook. Now I am coming to my site after clicking the link shared on Facebook. I want to capture the Facebook URL from where I am coming to my site. I want to get the referral site URL in my webapplication.
How do I get the referral site URL using C#?

You can use:
Request.UrlReferrer
More information on MSDN though I suspect there may be issues getting the referrer from Facebook, since FB connections are generally HTTPS and I'm pretty sure you don't get referrer info from HTTPS connections.
Good luck :)

Related

Send an HTTP Post request to a website that Requires a Login C#

I am trying to send a POST request to sites like Instagram and Facebook, which require you to login. I was wondering how i would go about sending the request as an actual Browser would. I have tried working with the Web Browser control in Windows Forms,I can load and log into the site, but I don't know how to send a POST request from the browser, or take the authentication, cookies, i really don't know what i need. Any help in pointing me in the right direction or perhaps explaining what i need to add to a HttpWebRequest or send through the WebBrowser control would be greatly Appreciated.
I'd provide code but as nothing has worked i don't see it helping much.

ADFS 2.0 signout redirect not functioning

In order to sign out of a web app using ADFS for authentication, using a URL that follows this form:
https://{DNS_name_of_RP_STS}/adfs/ls/?wa=wsignout1.0&wreply={post-sign-out_landing_URL}
works fine. The user is taken to an ADFS site page that notifies them that they've signed out. What isn't happening is redirecting back to the web app. I've spent a long time looking around online and I am pretty confused now as to if this is possible with the wreply parameter or not. There are a few spots on msdn and blogs where it is said to just work by supplying a wreply value, but it seems like most people are not having any luck with navigating back to the RP site.
Question: On signing out from ADFS, is it possible to automatically return to the RP app? Has anyone done this successfully? There's a "Sign in as different user" option that needs to end up with the user seeing the RP sign in page.
Thanks in advance to anyone who replies.
The url cannot be just any url but rather the same exact url your application is registered in adfs for.
The redirect works and always worked for us.

Referrer stripped when coming from Google site builder page?

Can anyone verify what I am seeing is not a bug? I am checking the referrer when someone comes to my site which is an ASP.NET C# store site. When I link from any of the other sites I control, my main page sees the referrer properly.
I am trying to support another third-party site that's linking to me and they have a Google site page at sites.google.com/site/whatever and when I follow that link my referrer on my main page is blank.
Is that something Google is doing or is it a truly bizarre bug in my code. (I know you can't see my code but I would like verification that Google is stripping referrer from their sites.google pages please.)
Thanks
Google Sites is HTTPS by default, which means no referrer data is passed. This may be part of Google's move to HTTPS across the board. Implications discussed here.
HTTP RFC says referrers shouldn't be sent when going from HTTPS to HTTP. Not sure if HTTPS to HTTPS will work either. See discussion here.

Azure ACS Facebook Error 191 redirect_uri is not owned by the application when Liking a page

I'm using the Facebook C# SDK to post a Like to Facebook from my ACS-secured web application but I'm getting the error:
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.
I believe the reason for this is because the url for the page I'm liking does not match the Facebook App Domain.
Details:
The page I'm trying to "Like" is (for example) http:// mysite.com/Story.aspx.
In ACS, the link to my secure login page is https:// mysite-acs.accesscontrol.windows.net/.
In Facebook, my app domain is mysite-acs.accesscontrol.windows.net and the Site URL under the "Website with Facebook Login" is: https:// mysite-acs.accesscontrol.windows.net/
The page I'm liking has the correct "og" tags and is on an unsecured page.
Is there any way I can get Facebook Like's working with ACS?
UPDATE: I've found a (temporary) solution.
I've found a workaround that allows me to have multiple Facebook App Domains but it is definitely not a perfect solution. The workaround is to specify the ACS url and the site url in the App Domains box. Then, under Website with Facebook Login I've entered the ACS url in the Site URL box, then, under Mobile Web, I've entered the site url in the Mobile Site URL box.
Now the link on Facebook works perfectly as Facebook can see the page on my site. I'm not going to mark the question as solved until I find the real solution, but hopefully it can help someone if they are stuck. Thanks for your responses. Much appreciated!
This is where you need to use a CNAME to point to your Azure site if you can. You do have conflicting domains which facebook will not allow. You can either add the accesscontrol.windows.net as your domain in Facebook or setup a CNAME in your DNS provider to point to accesscontrol.windows.net from 'mysite.com'.
Those are your options.
Hope this helps!

Getting the Google search terms from a https Google search

I want to get the search terms that user typed on Google to get to my long-tail landing page (and use them on that page).
Getting the the "q" variable from the query string using the response referrer (in ASP C#) works well but only if the referring Google page was not loaded as https.
This is obviously a problem due to the fact that almost everyone is logged in to their Google accounts on their browsers all the time and, if they are, all Google pages will be automatically loaded (and redirected) to use https.
When a user (on https://www.google.com) searches for something and clicks on a search result, Google seems to redirect the user to an intermediate page that strips the request of its query string and replaces it with a different one that pretty much only contains url that the intermediate page should redirect to (i.e. the url to my long-tail landing page).
Is there any way that I can get the original search terms that were used on https://www.google.com anyway? Maybe if JavaScript could access the browser history or something similar?
Is there any way that I can get the original search terms that were used on https://www.google.com
No, the full text of the https session is secured via SSL this includes headers, urls etc. In your scenario, for security reasons browers tend to omit the referer header therefore you won't be able to access it (unless the destination URL is also secured via HTTPS). This is part of the HTTP spec - 15.1.3 Encoding Sensitive Information in URI's.
The only thing you can do is put a disclaimer on your site to say it doesn't work over https.
Since it is Google, it is not possible because there is not shared link with your website.
Once you are on HTTPS - it does not allow sending of REFERRER headers. I am sure you are aware that headers can be manipulated and cannot be trusted but, you may trust Google. However, due to privacy policy any activity done on Google by Google users are not shared by 3rd party. Link
Again, in server side languages you can find functions for HTTP Referrer but not HTTPS referrer. That is for a reason !
Unless and until you do not have a collaboration with the originating server who may create an exception in their RFC thing to allow HTTP REFERRER ONLY for your website. It isn't possible.
Hope that helps! (in moving on) :)
EDIT: Wikipedia Link See Referrer Hiding (2nd last line)
To see the referrer data you need to be either a paying google ads customer (and the visitor come via an ad-click) or have your site in HTTPS as well. Certs are cheap these days or you could use an intermediary like CloudFlare to do the SSL and have a self-signed cert on your site.
You can also see queries no matter the method used, with Google Webmaster tools.
I wrote a little about this here: http://blogs.dixcart.com/public/technology/2012/03/say-goodbye-to-keyword-tracking.html

Categories