Reputation: 2653
I get a returned url from using facebook api:
But i am not sure how to get the token value? As its not in query string or Request.url
Any help?
Upvotes: 0
Views: 409
Reputation: 499092
You can't, assuming this is passed in on the current request, as anything after the #
is never sent to the server.
You can capture it in JavaScript and use AJAX to send it to the server, but this will be on a different request.
If you mean you have this URL not from the current request, you can use the Uri
class to parse a full URL and get the fragment:
var fragment = new Uri(theUri).Fragment;
var token = fragment.Split(new [] {'&','='}, StringSplitOptions.None)[1];
Upvotes: 1
Reputation: 3177
You have to look for "%23", because "#" is url-encoded to "%23"
reference: http://www.w3schools.com/tags/ref_urlencode.asp
But you have to know also, that anchors are not available on server side!
Upvotes: 0
Reputation: 5902
Check this Retrieving Anchor Link In URL for ASP.Net
you cannot get it from the server side, you will need to take if from client side first then pass it to the server in a hidden field or something similar
Upvotes: 0
Reputation: 82096
You can use HttpUtility.ParseQueryString to parse the URL then you can get the value by name e.g.
NameValueCollection query = HttpUtility.ParseQueryString(querystring);
string token = query["token"];
Upvotes: 0