public async Task <ActionResult> ConnectWithTrust(string endpointURL)
        {
            OpcSessionModel sessionModel = new OpcSessionModel {
                EndpointUrl = endpointURL
            };

            // Check that there is a session already in our cache data
            OpcSessionCacheData entry;

            if (OpcSessionHelper.Instance.OpcSessionCache.TryGetValue(Session.SessionID, out entry))
            {
                if (string.Equals(entry.EndpointURL, endpointURL, StringComparison.InvariantCultureIgnoreCase))
                {
                    OpcSessionCacheData newValue = new OpcSessionCacheData
                    {
                        CertThumbprint = entry.CertThumbprint,
                        OPCSession     = entry.OPCSession,
                        EndpointURL    = entry.EndpointURL,
                        Trusted        = true
                    };
                    OpcSessionHelper.Instance.OpcSessionCache.TryUpdate(Session.SessionID, newValue, entry);

                    return(await Connect(endpointURL));
                }
            }

            // Generate an error to be shown in the error view.
            // Since we should only get here when folks are trying to hack the site,
            // make the error generic so not to reveal too much about the internal workings of the site.
            Trace.TraceError(Strings.BrowserConnectErrorHeader);
            sessionModel.ErrorHeader = Strings.BrowserConnectErrorHeader;

            return(Json(sessionModel));
        }
        public ActionResult Index()
        {
            OpcSessionModel sessionModel = new OpcSessionModel();

            if (OpcSessionHelper.Instance.InitResult != "Good")
            {
                sessionModel.ErrorMessage = OpcSessionHelper.Instance.InitResult;
                return(View("Error", sessionModel));
            }

            OpcSessionCacheData entry = null;

            if (OpcSessionHelper.Instance.OpcSessionCache.TryGetValue(Session.SessionID, out entry))
            {
                sessionModel.EndpointUrl = entry.EndpointURL;
                Session["EndpointUrl"]   = entry.EndpointURL;
                return(View("Browse", sessionModel));
            }

            sessionModel.PrepopulatedEndpoints = new SelectList(_prepopulatedEndpoints, "Value", "Text");
            return(View("Index", sessionModel));
        }
        public ActionResult Index()
        {
            OpcSessionModel sessionModel = new OpcSessionModel
            {
                SessionId  = HttpContext.Session.Id,
                NodesetIDs = new SelectList(new List <string>())
            };

            OpcSessionCacheData entry = null;

            if (OpcSessionHelper.Instance.OpcSessionCache.TryGetValue(HttpContext.Session.Id, out entry))
            {
                sessionModel.ServerIP   = entry.EndpointURL.Host;
                sessionModel.ServerPort = entry.EndpointURL.Port.ToString();

                HttpContext.Session.SetString("EndpointUrl", entry.EndpointURL.AbsoluteUri);

                return(View("Browse", sessionModel));
            }

            UpdateStatus("Additional Information Required");
            return(View("Index", sessionModel));
        }