private string GenerateSignature(JSSDKViewModel model)
 {
     return SHA1_Hash(string.Format("jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}", model.JsApiTicket, model.NouceString, model.Timestamp, model.Url));
 }
        private async Task<JSSDKViewModel> ConstructJSSDKViewModel()
        {
            var jsSDKViewModel = new JSSDKViewModel
            {
                NouceString = "alibaba",
                Timestamp = 1464483842,//DateTime.Now.ToFileTime(),
                Url = string.Format("{0}://{1}{2}{3}", Request.Scheme, Request.Host.Value, Request.Path.Value, Request.QueryString.Value)
            };

            if (HttpRuntime.Cache.Get("JsApiTicket") == null)
            {
                using (var handler = new HttpClientHandler())
                {
                    handler.ClientCertificateOptions = ClientCertificateOption.Automatic;
                    using (var client = new HttpClient(handler))
                    {
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                        HttpResponseMessage response = await client.GetAsync(TokenUrl);
                        if (response.IsSuccessStatusCode)
                        {
                            TokenUrlResponse token = await response.Content.ReadAsAsync<TokenUrlResponse>();

                            response = await client.GetAsync(string.Format(TicketUrl, token.access_token));
                            TicketUrlResponse ticket = await response.Content.ReadAsAsync<TicketUrlResponse>();
                            if (ticket.ticket == null) ticket.ticket = "sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg";
                            HttpRuntime.Cache.Insert("JsApiTicket", ticket.ticket, null, DateTime.Now.AddSeconds(7000), Cache.NoSlidingExpiration, CacheItemPriority.High, null);
                        }
                    }
                }
            }
            jsSDKViewModel.JsApiTicket = HttpRuntime.Cache.Get("JsApiTicket") as string;
            jsSDKViewModel.Signature = GenerateSignature(jsSDKViewModel);

            jsSDKViewModel.JumpUrl = JumpUrl;

            return jsSDKViewModel;
        }