简体   繁体   中英

How to pull apart a querystring in C# when # provided instead of?

I use .NET 4.7, MVC5, C#

I am receiving a querystring from 3rd party endpoint which has a # in it instead of a ? ie:

endpoint#code=123456&parm2=123....

instead of:

endpoint?code=123456&parm2=123....

My usual code of:

string[] codes = Request.Params.GetValues("code")

or

string code = Request.QueryString["code"];

will not deal with this. Keeps returning null. I am unable to get 3rd party to change this, apparently it is part of the oauth2 spec, something called a "hash fragment".

Is it possible to get the full returned url and pulled the relevant bit out via string handling routines?

While I cannot see the full URL in the debugger, if I let the endpoint complete, I see the full querystring with the # in it with the URL box of the browser. Wish I could get this in code to splice.

Thoughts?

Thanks in advance.

The fragment (everything after the # sign) is not send to the server according to RFC 2396, section 4 :

However, "the URI" that results from such a reference includes only the absolute URI after the fragment identifier (if any) is removed and after any relative URI is resolved to its absolute form.

There is no way to retrieve it server side.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM