Asp.net 使用web api(ASP)搜索包含字符串参数的字符串。存储在JSON中的数据,包含网络驱动器中的文件列表

Asp.net 使用web api(ASP)搜索包含字符串参数的字符串。存储在JSON中的数据,包含网络驱动器中的文件列表,asp.net,json,angularjs,entity-framework,asp.net-web-api,Asp.net,Json,Angularjs,Entity Framework,Asp.net Web Api,我试图使用AngularJS向web api ASP查询一个字符串,web api ASP处理一个JSON文件,文件路径指向网络驱动器,并返回包含搜索字符串的所有文件名。我似乎找不到解决这个问题的好办法 我的模型: namespace RetGet.data { [DataContract] public class RetFil { [DataMember] public int Id { get; se

我试图使用AngularJS向web api ASP查询一个字符串,web api ASP处理一个JSON文件,文件路径指向网络驱动器,并返回包含搜索字符串的所有文件名。我似乎找不到解决这个问题的好办法

我的模型:

    namespace RetGet.data
   {
        [DataContract]
        public class RetFil
    {

        [DataMember]

        public int Id { get; set; }
        [DataMember]

        public string RetPath { get; set; }

    }
    }
在我的控制器中:

    //Ref to the model
    RetFil retfil = new RetFil();
    //Network drive path (Might have to change/Access permissions)
    string dirPath = @"HERE IS THE NETWORK DRIVE PATH";

    List<string> files;
    List<object> filesFormatted;



    public void SetUpLists()
    {

        //Collects all the .ret files in the dirPath and it's subfolders.
        files = new List<string>(Directory.GetFiles(dirPath, "*.ret", SearchOption.AllDirectories));
        filesFormatted = new List<object>();


    } 

    // GET: api/Ret/5
    [ResponseType(typeof(RetFil))]
    public IHttpActionResult GetRet(string id)
    {

        SetUpLists();

        //Adds each filename and format it (removing "\" from the file path) to the list of objects 
        foreach (var file in files)
        {

            var pathToString = file.Substring(file.LastIndexOf("\\"));
            if (pathToString.Contains(id))
            {
                filesFormatted.Add(new { pathToString });
            }

        }

        //Returns the list of object. Web Api will convert to JSON automatic.

        return Ok(filesFormatted); 
    }
当我试图从AngularJS中获取一些东西时,我会设法获取整个路径列表。要花很长时间为什么?我无法获取包含字符串参数的字符串


有什么建议可以解决这个问题吗?

目录搜索或返回客户端需要很长时间吗?使用chrome dev工具调试网络时,等待部分需要时间。其他的都是几毫秒。