Question: I'm using asp.net web service .asmx to transport json data. I have following code which seems not to be working.

```
    $.ajax({
            type: "POST",
            url: "../../App_Code/jsonWebService/getValue",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (output) {
                alert(output);
                $(config.captchaQuestion).html(output[0] + " + " + output[1] + " =");
                $(config.captchaHidden).val(output[2]);
            }
        });

```

And my code inside jsonWebService.cs of asmx file is:

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;

/// <summary>
/// Summary description for jsonWebService
// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment        the following line. 
 [System.Web.Script.Services.ScriptService]
public class jsonWebService : System.Web.Services.WebService {

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Array getValue()
{
    Random getRandom = new Random();
    int rand1 = getRandom.Next(0, 9);
    int rand2 = getRandom.Next(0, 9);
    int sum = rand1 + rand2;
    int[] jsonObject = new int[3] { rand1, rand2, sum };
    return jsonObject;
}

}

```

And I'm getting Forbidden error 403. Thanks in advance.

Answer: 
you need to convert your text into array first, because what your doing right now includes a `,` in your regexp pattern

```
$stop_ips_masks = file_get_contents('array.txt');
$stop_ips_masks = explode("," $stop_ips_masks);

```

You might also need to do a trim operation and remove the newlines as well. it would be easier if you stick to one record separator. like comma or newline. not both.

If you remove the `,` from your text file then you can do

```
$stop_ips_masks = file('array.txt');

```
I believe your issue is the quotes and tailing comma. While needed to make a array in php they are invalid when sourced from the file. 

```
    $stop_ips_masks = file('array.txt', FILE_IGNORE_NEWLINES);
    foreach ( $stop_ips_masks as $k=>$v )
    {
          $v = trim(rtrim($v, ","), '"');
          if ( preg_match( '#^'.$v.'$#', $_SERVER['REMOTE_ADDR']) )
          echo found;
    }

```