ServiceStack例外:“处理程序请求没有找到要插入进入​​到SqlLite分贝时, [英] ServiceStack Exception: 'Handler for Request not found' when trying to insert Entry to SqlLite db

查看:177
本文介绍了ServiceStack例外:“处理程序请求没有找到要插入进入​​到SqlLite分贝时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是学习如何使用ServiceStack和我得到一个例外,我不能让过去并不能确定是什么原因造成的除外。在这里,它是:

 找不到处理程序的要求:

Request.ApplicationPath:/
Request.CurrentExecutionFilePath:/项/ 5 /二零一二年十一月十一日
Request.FilePath:/项/ 5/2012年11月11号
Request.HttpMethod:GET
Request.MapPath('〜'):C:\项目\教程\ FirstServiceStackApp \ FirstServiceStackApp \
Request的:/项/ 5 /二〇一二年十一月十一日
Request的PathInfo:
Request.ResolvedPathInfo:/项/ 5/2012年11月11号
Request.PhysicalPath:C:\项目\教程\ FirstServiceStackApp \ FirstServiceStackApp \入门\ 5 \ 2012年11月11日
Request.PhysicalApplicationPath:C:\项目\教程\ FirstServiceStackApp \ FirstServiceStackApp \
的Request.QueryString:
Request.RawUrl:/项/ 5 /二〇一二年十一月十一日
Request.Url.AbsoluteUri:HTTP://本地主机:52920 /项/ 5/2012年11月11号
Request.Url.AbsolutePath:/项/ 5/2012年11月11号
Request.Url.Fragment:
Request.Url.Host:本地主机
Request.Url.LocalPath:/项/ 5/2012年11月11号
Request.Url.Port:52920
Request.Url.Query:
Request.Url.Scheme:HTTP
Request.Url.Segments:System.String []
App.IsIntegratedPipeline:真
App.WebHostPhysicalPath:C:\项目\教程\ 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:元
App.DebugLastHandlerArgs: GET|/entry/5/11-11-2012|C:\Projects\Tutorials\FirstServiceStackApp\FirstServiceStackApp\entry\5\11-11-2012
 

我要通过ServiceStack约翰SONMEZ的优秀Pluralsight当然,和刚才说的OrmLite件到我的项目。当我尝试添加新条目,抛出此异常。所以,我没有SqlLite文件尚未在我的App_Data文件夹中,并没有被创建。它不是在code打破,当我尝试调试,所以不知道去哪里找这个...

修改:增加了有关人士code:

  [路径(/项/ {量} / {EntryTime},POST)
公共类条目{...}

公共类EntryService:服务
{
    公共TrackedDataRepository TDRepository {获得;组; }

    公开对象的任何(入学要求)
    {
        VAR ID = TDRepository.AddEntry(要求);
        返回新EntryResponse {n = ID};
    }
}
 

解决方法:

删除发表在路由定义过滤器以使其适用于所有航线:

  [路径(/项/ {量} / {EntryTime})]
 

解决方案

嗯 - 不知道这是一个OrmLite问题。如果我没有理解异常消息正确它在暗示你没有一个服务类**用正确的方法,包括就可以了。在这种情况下,因为HttpMethod是让您的服务类将需要有一个获取(或)方法就可以了。

你有一个服务类像下面。

 公共类EntryService:服务//确保从服务或RestServiceBase&LT继承;进入>
{
    公共对象获取(进入请求)
    {
        //这里处理请求
    }
}
 

更新1: 您还需要有路由正确的Entry类。在你的情况,因为你要添加2个参数(/ 5/2012年11月11号),你将需​​要2路由参数(或者用通配符)。

  [路径(/项/ {P1} / {P2})] //或使用/输入/ {P1 *}使用通配符
公共类条目
{
    公共字符串P1 {获得;组;}
    公共字符串P2 {获得;组;}
}
 

**服务类是你的类继承的服务/ RestServiceBase,这是什么'处理'您的要求(在本例中输入),并返回你的回应(一般以下的名称约定{}的请求的响应eg.EntryResponse) 。

I'm just learning how to use ServiceStack and I am getting an exception that I can't get past and not sure what is causing the exception. Here it is:

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

I'm going through John Sonmez's excellent Pluralsight course on ServiceStack, and have just added the OrmLite piece to my project. This exception is thrown when I attempt to add a new Entry. So I have no SqlLite file yet in my App_Data folder, and none is created. It's not breaking in the code when I try to debug, so not sure where to look for this...

Edit: Added relevant Source Code:

[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}; 
    } 
} 

Solution:

Remove POST filter on Route definition so it applies to all routes:

[Route("/entry/{Amount}/{EntryTime}")]

解决方案

Hmm - Not sure this is a OrmLite issue. If I understand the exception message correctly it is hinting that you don't have a 'service class**' with the correct method included on it. In this case since the HttpMethod is Get your service class would need to have a Get (or Any) method on it.

Do you have a 'service class' like below.

public class EntryService : Service //make sure inheriting from Service or RestServiceBase<Entry> 
{
    public object Get(Entry request)
    {
        //handle request here
    }
}

Update 1: You will also need to have your Entry class 'routed' correctly. In your case since your are adding 2 parameters (/5/11-11-2012) you'll need 2 route parameters (or one with a wildcard).

[Route("/Entry/{P1}/{P2}")] //or use /Entry/{P1*} to use wildcard
public class Entry
{
    public string P1 {get; set;}
    public string P2 {get; set;}
}

**service class is your class that inherits from Service/RestServiceBase and it is what 'handles' your request (in this case Entry) and returns your response (generally following the name convention of {request}Response eg.EntryResponse).

这篇关于ServiceStack例外:“处理程序请求没有找到要插入进入​​到SqlLite分贝时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆