Link to home
Start Free TrialLog in
Avatar of rp
rpFlag for Portugal

asked on

Error on Credentials, converting c# to vb.net

Hi,


After converting c# to vb.net a piece of code i have an error on Credentials:

 Dim httpReq As HttpWebRequest = CType(WebRequest.Create(New Uri(TokUri)), HttpWebRequest)
        httpReq.Method = "POST"         httpReq.KeepAlive = True         httpReq.AllowAutoRedirect = True         httpReq.PreAuthenticate = False         Dim cred As Credentials = New Credentials() With {             .username = username,             .password = password         }

Open in new window

Visual studio not recognize Credentials and says "Type: Credentials is not dfined"

best regards

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

are you missing an import (using) like System.Net?
Avatar of rp

ASKER

I don't know if there's any more, but Imports System.Net is here.

best regards
ASKER CERTIFIED SOLUTION
Avatar of Ron Malmstead
Ron Malmstead
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use the secure string function when storing passwords.

Do you need to create that object? You could directly assign it to your httpReq instance.

I have this working code:
httpReq.Credentials = New NetworkCredential(username, password)

Open in new window