首页 > 代码库 > C# 后台获取请求来源
C# 后台获取请求来源
/// <summary> /// 下载APP /// </summary> /// <returns></returns> [AllowAnonymous] [Route("download/app")] public ActionResult DownloadApp() { string android = "android"; //获取客服端请求源 string agent = Request.UserAgent; string[] keywords = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" }; // CloudWave.Framework.Core.Logging.Logging4net.WriteInfo(agent); //排除 Windows 桌面系统 //if (!agent.Contains("Windows NT") || (agent.Contains("Windows NT") && agent.Contains("compatible; MSIE 9.0;"))) var downloadurl = ""; //判断是微信, 直接响应应用宝地址 if (agent.ToLower().Contains("micromessenger")) { //获取配置信息 var wxUrl = ConfigurationManager.AppSettings["YingYongBao"]; if (!string.IsNullOrEmpty(wxUrl)) { return Redirect(wxUrl); } return RedirectToAction("index"); } if (agent.ToLower().Contains(android)) { downloadurl = ConfigurationManager.AppSettings["AndroidUrl"]; if (string.IsNullOrEmpty(downloadurl)) { return RedirectToAction("index"); } } else { downloadurl = ConfigurationManager.AppSettings["IOSUrl"]; if (string.IsNullOrEmpty(downloadurl)) { return RedirectToAction("index"); } if (agent.ToLower().Contains("weibo")) { downloadurl = "itms-apps" + downloadurl.Substring(downloadurl.IndexOf(":")); //itms-apps:// } } return Redirect(downloadurl); }
C# 后台获取请求来源
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。