【问题标题】:parameters not recognized following decimal values十进制值后无法识别的参数
【发布时间】:2017-09-19 16:55:32
【问题描述】:

如果前面的参数(纬度和经度)在 URL 中没有小数点,ServiceStack 会识别参数(在我的例子中是 RADIUS)。一旦我将小数点放在纬度或经度上,我就会得到一个“未找到请求的处理程序”。以下是我的代码和错误

这里是位置类

public class Location
{
    [DataMember(Name = "Latitude", Order = 5)]
    public double? LATITUDE { get; set; }
    [DataMember(Name = "Longitude", Order = 6)]
    public double? LONGITUDE { get; set; }
    [DataMember(Name = "Radius", Order = 7)]
    public double? RADIUS { get; set; }
}

这是我的 AppHost 路径定义

Routes.Add<Location>("/Locate/geo/{LATITUDE}/{LONGITUDE}", "GET");
Routes.Add<Location>("/Locate/geo/{LATITUDE}/{LONGITUDE}/rad/{RADIUS}", "GET");
Routes.Add<Location>("/Locate/rad/{RADIUS}/geo/{LATITUDE}/{LONGITUDE}", "GET");

以下是我的结果

有效

http://localhost:2222/api/Locate/geo/30.1783/-96.3911?format=xml
http://localhost:2222/api/Locate/rad/20/geo/30.1783/-96.3911?format=xml

没有用

http://localhost:2222/api/Locate/geo/30.1783/-96.3911/rad/20?format=xml 

- 我收到以下错误

未找到请求的处理程序:

Request.ApplicationPath: /

Request.CurrentExecutionFilePath: /api/Locate/geo/30.1783/-96.3911

Request.FilePath: /api/Locate/geo/30.1783/-96.3911

Request.HttpMethod: GET

Request.MapPath('~'): C:\Webservices\

请求路径:/api/Locate/geo/30.1783/-96.3911/rad/20

Request.PathInfo: /rad/20

Request.ResolvedPathInfo: /rad/20

Request.PhysicalPath: C:\Webservices\api\Locate\geo\30.1783-96.3911

Request.PhysicalApplicationPath: C:\Webservices\

Request.QueryString:格式=xml

Request.RawUrl:/api/Locate/geo/30.1783/-96.3911/rad/20?format=xml

Request.Url.AbsoluteUri:http://localhost:2222/api/Locate/geo/30.1783/-96.3911 /rad/20?format=xml

Request.Url.AbsolutePath: /api/Locate/geo/30.1783/-96.3911/rad/20

Request.Url.Fragment:

Request.Url.Host: 本地主机

Request.Url.LocalPath:/api/Locate/geo/30.1783/-96.3911/rad/20

Request.Url.Port: 2222

Request.Url.Query: ?format=xml

Request.Url.Scheme:http

Request.Url.Segments:System.String[]

App.IsIntegratedPipeline:假

App.WebHostPhysicalPath: C:\Webservices

App.DefaultHandler: DefaultHttpHandler

App.DebugLastHandlerArgs: GET|/api/Locate/geo/30.1783/-96.3911|C:\Webservices\api\Locate\geo\30.1783-96.3911

如果小数是问题,想知道第一个带有 Lat 和 Long 的 URL 如何在小数位下工作。如果任何 AppHost 路径错误,请纠正我。

【问题讨论】:

    标签: servicestack


    【解决方案1】:

    From this previous answer:

    ServiceStack 的路由中有 2 个组件分隔符:./,这是一个显示 different Route path ServiceStack supports 的示例。

    您可以尝试对 . 进行 url 编码,使其成为 %2E,否则只需将操作添加为查询字符串参数,例如:/path/to/me%40example.com?action=action

    【讨论】:

    • 感谢您的快速回复。将尝试替代品。
    猜你喜欢
    • 2021-07-23
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-13
    • 1970-01-01
    • 2019-07-14
    • 2013-08-09
    相关资源
    最近更新 更多