Блог им. hate2trd
using System; using System.Net; using System.Text; namespace AuthMoexSmpl { class Program { static void Main(string[] args) { string authLink = "https://passport.moex.com/authenticate"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authLink); request.ContentType = "text/plain; charset=utf-8"; request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("login:password")); //свои данные request.PreAuthenticate = true; request.CookieContainer = new CookieContainer(); HttpWebResponse response = request.GetResponse() as HttpWebResponse; for(int i=0; i < response.Headers.Count; ++i) Console.WriteLine("\nHeader Name:{0}, Value :{1}",response.Headers.Keys[i],response.Headers[i]); } } }
D:\devel\net\AuthMoexSmpl>dotnet run Header Name:Cache-Control, Value :no-store, must-revalidate, no-cache, ma Header Name:Connection, Value :close Header Name:Date, Value :Fri, 10 Nov 2017 19:53:12 GMT Header Name:Pragma, Value :no-cache Header Name:ETag, Value :"xxxxxx" Header Name:Server, Value :nginx Header Name:Set-Cookie, Value :MicexPassportCert=xxxxxxx; domain=.moex.com; path=/, _passport_se m xxxxx; path=/; HttpOnly Header Name:Status, Value :200 OK Header Name:X-Runtime, Value :713 Header Name:X-Moex-Passport-Certificate, Value :xxxxxx Header Name:X-Powered-By, Value :Phusion Passenger 4.0.57 Header Name:Access-Control-Allow-Credentials, Value :true Header Name:Access-Control-Expose-Headers, Value :X-MicexPassport-Marker