Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将参数传递给Nancy Route_C#_Node.js_Nancy - Fatal编程技术网

C# 将参数传递给Nancy Route

C# 将参数传递给Nancy Route,c#,node.js,nancy,C#,Node.js,Nancy,我之前有一个Web服务,其方法如下: public class DxDService : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)] public string GetSData(string strFirstName, string strLastName, string strDOB,

我之前有一个Web服务,其方法如下:

public class DxDService : System.Web.Services.WebService
{
   [WebMethod]
   [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
   public string GetSData(string strFirstName, string strLastName, string strDOB, string strSource, SortDetails sortDetails, string ID)
   {
        //manipulate the params and used to return data
   }
}
我在我的
NodeJS
应用程序中使用了这个
Webservice
,下面是一段代码

var soap=require('soap')

var url = 'http://serverName/DxDService.asmx?wsdl';
var args={'strFirstName':req.actions.firstName,'strLastName':req.actions.lastName, 'strDOB':req.actions.dob, 'strSource':'PtSearch','sortDetails':sort,'ID':''};
soap.createClient(url, function(err, client) {
      client.GetSData(args,function(err, result) {
          req.res = result;
          next();
      });
});
但作为升级的一部分,我们将从Web服务转移到Windows服务,该服务在启动时在本地系统中创建一个主机,该主机将具有此
Web服务的功能。我在这里使用启动
主机
。但我对如何像在web服务中一样在Nancy Routes中接收参数感到困惑。下面是我现在在
Windows服务中的内容

Service1.cs

private NancyHost host;
protected override void OnStart(string[] args)
{
     var url = "http://127.0.0.1:port";
     this.host = new NancyHost(new Uri(url));
     this.host.Start();
}
public class RootRoutes : NancyModule
{
    public RootRoutes()
    {
        //This should be same as GetSData method in webservice but this acts as Route
        Get["/GetSData"] = parameters =>
        {
            //How can I access params here as I did in webservice method?
            //below is just a sample piece of code showing what returns on browsing
            http://127.0.0.1:port/GetSData

            var test = new
            {
                Name = "Guruprasad Rao",
                Twitter="@kshkrao3",
                Occupation="Software Developer"
            };
            return Response.AsJson(test);
        };
    }
}
RootRoutes.cs实现了NancyModule

private NancyHost host;
protected override void OnStart(string[] args)
{
     var url = "http://127.0.0.1:port";
     this.host = new NancyHost(new Uri(url));
     this.host.Start();
}
public class RootRoutes : NancyModule
{
    public RootRoutes()
    {
        //This should be same as GetSData method in webservice but this acts as Route
        Get["/GetSData"] = parameters =>
        {
            //How can I access params here as I did in webservice method?
            //below is just a sample piece of code showing what returns on browsing
            http://127.0.0.1:port/GetSData

            var test = new
            {
                Name = "Guruprasad Rao",
                Twitter="@kshkrao3",
                Occupation="Software Developer"
            };
            return Response.AsJson(test);
        };
    }
}

如何才能做到这一点?非常感谢您的任何想法/帮助。

使用string
searchTerm=this.Request.Query[“term”]
获取所有get方法请求参数