Username and Password data Windows phone 8 app

后端 未结 2 1797
梦谈多话
梦谈多话 2021-01-23 11:32

I am writing a Windows phone 8 app that is using an API to pull in some data that the app will need and to use the api, a username and password is required. I have been supplie

2条回答
  •  没有蜡笔的小新
    2021-01-23 12:08

    I don't know of any concerns that require you to style your code any different form normal

    WebRequest request = WebRequest.Create("http://SomeProtectedUrl.com");
    request.Credentials = new System.Net.NetworkCredential("username", "password");
    

    to keep your username and password in a single spot, so that it would be easy to change you could use

    public static string uname = "yourUsername";
    public static string passwd= "yourPassword";
    
    request.Credentials = new System.Net.NetworkCredential(uname, passwd);
    

提交回复
热议问题