C# (.Net)
The following code example is written in C#, for use with the .NET framework:
- /* set up the SecureKey call */
- // define parts of the SecureKey request URL
- string strLogiAppBaseURL = "http://<yourServer>/<LogiApp>";
- string UserName = "Bob";
- string Roles = "Admin";
- string Rights = "Manager";
- string ClientBrowserAddress = Request.ServerVariables["REMOTE_ADDR"];
- // build complete URL to Logi app
- string sGetKeyURl = "/rdTemplate/rdGetSecureKey.aspx?Username=" + UserName + "&Rights=" + Rights + "&Roles=" + Roles + "&ClientBrowserAddress=" + ClientBrowserAddress;
- string sFinalURL = strLogiAppBaseURL + sGetKeyURl;
- // create and send SecureKey request
- string sKey = "";
- HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(sFinalURL);
- HttpWebResponse webResponse;
- // attempt to make SecureKey call, read return into sKey
- try
- {
- webResponse = (HttpWebResponse)webRequest.GetResponse();
- Stream myStream;
- myStream = webResponse.GetResponseStream();
- StreamReader sr = new StreamReader(myStream);
- sKey = sr.ReadToEnd();
- }
- catch (Exception ex) // if not bad URL, send error message
- {
- if (ex.Message.IndexOf("401") != -1)
- {
- Response.Write("Not Found");
- }
- else
- {
- Response.Write(ex.Message.ToString());
- }
- }