Related topic:
-
Getting Started
Get a token with your credentials before you access DAC Web site.
-
Example Code of C#
public ActionResult LoginDACAuth()
{
string token = GetToken(url + "Api/GetToken", "TestA", "123456");
Response.Redirect(url + "Auth/Login?token=" + token + "&account=");
return null;
}
protected string GetToken(string uri,string userName, string password)
{
string retVal = "";
try
{
string _auth = string.Format("{0}:{1}", userName, password);
string _enc = Convert.ToBase64String(Encoding.ASCII.GetBytes(_auth));
string _cred = string.Format("{0} {1}", "Basic", _enc);
WebRequest request = WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = "text/xml";
request.Headers[HttpRequestHeader.Authorization] = _cred;
request.Headers.Add("Action", "GetToken");
request.Headers.Add("ClientIP", System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
request.ContentLength = 0;
System.Net.WebResponse response = request.GetResponse();
System.IO.StreamReader reader = new StreamReader(response.GetResponseStream());
string str = reader.ReadToEnd();
XmlDocument xd = new XmlDocument();
xd.LoadXml(str);
foreach (XmlNode xn in xd.ChildNodes)
{
retVal = xn.InnerText;
}
}
catch (Exception e)
{
}
return retVal;
}
-
Contsct us
jcui@dacgroup.com