我只是在学习如何使用 ServiceStack,但遇到了一个我无法通过的异常,并且不确定是什么导致了异常。这里是:
Handler for Request not found:
Request.ApplicationPath: /
Request.CurrentExecutionFilePath: /entry/5/11-11-2012
Request.FilePath: /entry/5/11-11-2012
Request.HttpMethod: GET
Request.MapPath('~'): C:\Projects\Tutorials\FirstServiceStackApp\FirstServiceStackApp\
Request.Path: /entry/5/11-11-2012
Request.PathInfo:
Request.ResolvedPathInfo: /entry/5/11-11-2012
Request.PhysicalPath: C:\Projects\Tutorials\FirstServiceStackApp\FirstServiceStackApp\entry\5\11-11-2012
Request.PhysicalApplicationPath: C:\Projects\Tutorials\FirstServiceStackApp\FirstServiceStackApp\
Request.QueryString:
Request.RawUrl: /entry/5/11-11-2012
Request.Url.AbsoluteUri: http://localhost:52920/entry/5/11-11-2012
Request.Url.AbsolutePath: /entry/5/11-11-2012
Request.Url.Fragment:
Request.Url.Host: localhost
Request.Url.LocalPath: /entry/5/11-11-2012
Request.Url.Port: 52920
Request.Url.Query:
Request.Url.Scheme: http
Request.Url.Segments: System.String[]
App.IsIntegratedPipeline: True
App.WebHostPhysicalPath: C:\Projects\Tutorials\FirstServiceStackApp\FirstServiceStackApp
App.WebHostRootFileNames: [entry.cs,entryservice.cs,firstservicestackapp.csproj,firstservicestackapp.csproj.user,global.asax,global.asax.cs,packages.config,recordipfilter.cs,statusquery.cs,statusservice.cs,web.config,web.debug.config,web.release.config,app_data,bin,obj,properties,scripts,x64,x86]
App.DefaultHandler: metadata
App.DebugLastHandlerArgs: GET|/entry/5/11-11-2012|C:\Projects\Tutorials\FirstServiceStackApp\FirstServiceStackApp\entry\5\11-11-2012
我正在学习 John Sonmez 关于 ServiceStack 的优秀 Pluralsight 课程,并且刚刚将 OrmLite 部分添加到我的项目中。当我尝试添加新条目时会引发此异常。所以我的 App_Data 文件夹中还没有 SqlLite 文件,也没有创建任何文件。当我尝试调试时,它并没有破坏代码,所以不知道在哪里寻找这个......
编辑:添加了相关的源代码:
[Route("/entry/{Amount}/{EntryTime}", "POST")]
public class Entry { ... }
public class EntryService : Service
{
public TrackedDataRepository TDRepository { get; set; }
public object Any(Entry request)
{
var id = TDRepository.AddEntry(request);
return new EntryResponse {Id = id};
}
}
解决方案:
删除路由定义上的POST过滤器,使其适用于所有路由:
[Route("/entry/{Amount}/{EntryTime}")]