Пример #1
0
 public override void OnActionExecuting(ActionExecutingContext context)
 {
     ValidateRequest();
     ViewBag.culture = culture;
     if (!string.IsNullOrEmpty(culture))
     {
         ViewBag.assetFolder = MixCmsHelper.GetAssetFolder(culture);
     }
     domain = string.Format("{0}://{1}", Request.Scheme, Request.Host);
     if (MixService.GetIpConfig <bool>("IsRetrictIp"))
     {
         var    allowedIps = MixService.GetIpConfig <JArray>("AllowedIps") ?? new JArray();
         var    exceptIps  = MixService.GetIpConfig <JArray>("ExceptIps") ?? new JArray();
         string remoteIp   = Request.HttpContext?.Connection?.RemoteIpAddress?.ToString();
         if (
             // To allow localhost remove below comment
             //remoteIp != "::1" &&
             allowedIps.Count > 0 &&
             !allowedIps.Any(t => t["text"].Value <string>() == remoteIp) ||
             (
                 exceptIps.Count > 0 &&
                 exceptIps.Any(t => t["text"].Value <string>() == remoteIp)
             )
             )
         {
             forbidden = true;
         }
     }
 }