Others have already posted answers to your specific problem.
But it seems like you are developing an ASP.NET website so you should consider using the standard ?
instead of #
to prefix your query string.
This will allow you to use built-in methods and properties for processing the query string and avoid custom error-prone string processing:
string queryString = Request.Url.Query; // gives you "state=test&access_token=...."
or access it as a NameValueCollection:
string state = Request.QueryString["state"]; // gives you "test"