Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

HttpWebRequest.PreAuthenticate Property missing

NETMF HTTP

  • Please log in to reply
1 reply to this topic

#1 Pablo

Pablo

    New Member

  • Members
  • Pip
  • 7 posts

Posted 21 January 2013 - 05:44 AM

I'm trying to read data from a JPG image from a URL with authentication. This is an example in C #, but not for NETMF.

In NETMF 4.2,I  can't find the property Preauthenticate.

As I read you need to set its value to "true" to effectively accompany credentials.

 

Someone could help me with an example that reads an image from a password-protected URL, and guide me on how to read the Stream, as the examples found on the Internet using Image.FromStream class, which is not found in. NETMF

 

Regards, Pablo

                     // Create a new webrequest to the mentioned URL.            WebRequest myWebRequest=WebRequest.Create(url);            // Set 'Preauthenticate'  property to true.  Credentials will be sent with the request.            myWebRequest.PreAuthenticate=true;            Console.WriteLine("nPlease Enter ur credentials for the requested Url");                     Console.WriteLine("UserName");            string UserName=Console.ReadLine();            Console.WriteLine("Password");            string Password=Console.ReadLine();            // Create a New 'NetworkCredential' object.            NetworkCredential networkCredential=new NetworkCredential(UserName,Password);            // Associate the 'NetworkCredential' object with the 'WebRequest' object.            myWebRequest.Credentials=networkCredential;            // Assign the response object of 'WebRequest' to a 'WebResponse' variable.            WebResponse myWebResponse=myWebRequest.GetResponse();

 



#2 dustmouse

dustmouse

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationEdgewater, CO

Posted 22 January 2013 - 03:55 PM

Do you know if the website you are trying to authenticate uses cookies-based authentication?  If so, even in standard .NET, it's not very straightforward to accomplish (the example you provided probably won't work).

 

If it is non-cookies based, do you need to use the PreAuthenticate property?  Or can you just accomplish the authentication with the Credentials property, which the NETMF implementation should support.


Check out my Netduino projects on GitHub.






Also tagged with one or more of these keywords: NETMF, HTTP

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.