Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpWebRequest odd behaviour
    primarykey
    data
    text
    <p><strong>UPDATE</strong> It looks as though the issue is related to <a href="https://stackoverflow.com/questions/10531575/passing-a-dynamic-parameter-throws-runtimebinderexception-when-calling-method-fr">this</a>. I have this chunk of code to deal with:</p> <pre><code>dynamic facebookResponse = facebookClient.Batch(new FacebookBatchParameter(HttpMethod.Get, "me"), new FacebookBatchParameter(HttpMethod.Get, "me", new { fields = "picture.type(large)" })); </code></pre> <p>Errr not sure why this is happening!</p> <p>I found some odd behaviour HttpWebRequest.</p> <pre><code>// Send the image to blob storage. var url = facebookResponse[1]["picture"]["data"]["url"]; byte[] imageBytes; var request = (HttpWebRequest)HttpWebRequest.Create(url); request.Timeout = 5000; request.ReadWriteTimeout = 20000; var response = (HttpWebResponse)request.GetResponse(); var validationResults = _imageService.UploadProfilePicture(response, url, newUserId).ToList(); </code></pre> <p>On the last line its throwing an error saying <code>'object' does not contain a definition for 'ToList'</code> but if I take out all of the lines before the last line it will step into the function.</p> <p>Possible threading issue maybe?</p> <p>EDIT: _imageService is just a dependency passed into the controller with Ninject. </p> <p>Here's the UploadProfilePicture function:</p> <pre><code>public IEnumerable&lt;ValidationResult&gt; UploadProfilePicture(Stream s, string fileName, int userId) { if (s == null) throw new ArgumentNullException("s"); if (userId &lt;= 0) throw new ArgumentNullException("userId"); if (s.Length &lt;= 0) { yield return new ValidationResult("", GlobalResources.FileContainsNoContent); yield break; } var maxProfilePictureSize = int.Parse(ConfigurationManager.AppSettings[ConfigurationManagerConstants.BlobMaxProfilePictureSize]); if (s.Length &gt; maxProfilePictureSize) { yield return new ValidationResult("", string.Format(GlobalResources.ProfilePictureMustBeNoGreaterThan, ConfigurationManager.AppSettings[ConfigurationManagerConstants.BlobMaxProfilePictureSizeFriendlyText])); yield break; } const string defaultExtensionType = ".jpg"; var container = GetCloudBlobContainer(ConfigurationManager.AppSettings[ConfigurationManagerConstants.BlobImageContainerName]); var uniqueBlobName = string.Format(ConfigurationManager.AppSettings[ConfigurationManagerConstants.BlobUserProfilePicturePath], userId, defaultExtensionType); var blob = container.GetBlockBlobReference(uniqueBlobName); blob.Properties.ContentType = "image/jpeg"; var uploadImageExtension = Path.GetExtension(fileName); if (!string.IsNullOrWhiteSpace(uploadImageExtension) &amp;&amp; !uploadImageExtension.Equals(defaultExtensionType, StringComparison.InvariantCultureIgnoreCase)) { using (var ms = new MemoryStream()) { ImageBuilder.Current.Build(s, ms, new ResizeSettings("format=jpg")); ms.Seek(0, SeekOrigin.Begin); blob.UploadFromStream(ms); } } else { blob.UploadFromStream(s); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload