如果前面的参数(纬度和经度)在URL中没有小数,ServiceStack会识别参数(在我的情况下为RADIUS)。一旦我在纬度或经度中放置小数,我得到一个“找不到请求的处理程序”。以下是我的代码和错误
这是Location类
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 \
Request.Path:/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:format = 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 /弧度/ 20?格式= XML
Request.Url.AbsolutePath:/api/Locate/geo/30.1783/-96.3911/rad/20
Request.Url.Fragment:
Request.Url.Host:localhost
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:False
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
如果小数是问题,那么第一个URL如何同时包含Lat&amp;长时间使用小数位。如果任何AppHost路径错误,请纠正我。
答案 0 :(得分:1)
ServiceStack的路由中有2个组件分隔符:.
和/
,这是一个显示different Route path ServiceStack supports的示例。
您可以尝试对.
进行网址编码,使其为%2E
,否则只需将操作添加为查询字符串参数,例如:/path/to/me%40example.com?action=action