c# - HttpResponseMessage System.InvalidOperationException -
quite simple problem i've got easy solve reckon brains. it's tried different queries on google , nothing popped hey that's why here.
here error: system.invalidoperationexception
basically error thrown on piece of code here
string test = response.content.headers.getvalues("location").firstordefault();
location in fiddler looks this:
location: https://www.redirecturlishere.com/blah
here entire function:
private async task<string> getrequest() { //httpcontent postcontent = new stringcontent(post, encoding.ascii, "application/x-www-form-urlencoded"); using (httpresponsemessage response = await httpclient.getasync( "http://www.cant-share-url.com")) { using (httpcontent content = response.content) { string test = response.content.headers.getvalues("location").firstordefault(); } } return ""; }
more details on error, "additional information: misused header name. make sure request headers used httprequestmessage, response headers httpresponsemessage, , content headers httpcontent objects."
i don't think there else explain i'll leave @ that.
i have solved problem header not stored in content, silly me.
and doesn't see solution. :)
string test = response.headers.getvalues("location").firstordefault()
Comments
Post a Comment