我有一个网站在iis7承载几个openrasta应用程序作为虚拟目录。其中一个openrasta应用程序托管一个资源,所以我希望它在该虚拟目录的根目录下运行。我能够成功获取资源,但无法发布资源。当发布时,我得到了一个405错误。Openrasta张贴到资源在基地uri
本地,它看起来像:
http://localhost/OpenRastaApp1/Resource1 http://localhost/OpenRastaApp1/Resource2 http://localhost/OpenRastaApp2/Resource3 http://localhost/OpenRastaApp2/Resource4
我要添加其他应用程序,但这个程序将只包含1个资源我希望通过应用程序的基础URI来访问它。即
http://localhost/OpenRastaApp3 not http://localhost/OpenRastaApp3/Resource5
我能够GET资源5,但无法使用以下配置发布到它。
它不应该与模板“/ {id}”匹配,因为我在发布时不包含ID。
我的配置如下:
ResourceSpace.Has
.ResourcesOfType<ThingResource>()
.AtUri("/").And
.AtUri("/{id}")
.HandledBy<ThingHandler>()
.AsJsonDataContract();
我的处理程序代码是:
public class ThingHandler
{
[HttpOperation(HttpMethod.POST)]
public OperationResult Post(ThingResource thingResource)
{
var thing = thingResource.ToThingEntity();
thing = _thingService.Make(thing);
return new OperationResult.OK(thing.ToThingResource());
}
[HttpOperation(HttpMethod.GET)]
public OperationResult Get(int id)
{
var thing = _thingService.Get(id);
return new OperationResult.OK(thing.ToThingResource());
}
}
调试日志如下
13-[2011-03-01 10:38:59Z] Verbose(0) Incoming host request for http://api.local.site.com/Thing 13-[2011-03-01 10:38:59Z] Verbose(0) Adding communication context data 13-[2011-03-01 10:38:59Z] Warning(0) Contributor call for BootstrapperContributor had a null Action. 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor ExceptionHandlerContributor.LogException 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor HttpMethodOverriderContributor.OverrideHttpVerb 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor DigestAuthorizerContributor.ReadCredentials 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor UriDecoratorsContributor.ProcessDecorators 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor ResourceTypeResolverContributor.ResolveResource 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor HandlerResolverContributor.ResolveHandler 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor OperationCreatorContributor.CreateOperations 13-[2011-03-01 10:38:59Z] Verbose(0) Created operation named Post with signature ThingHandler::Post(ThingResource ThingResource) 13-[2011-03-01 10:38:59Z] Verbose(0) Created operation named Get with signature ThingHandler::Get(Int32 id) 13-[2011-03-01 10:38:59Z] Verbose(0) Created operation named Amend with signature ThingHandler::Amend(ThingResource ThingResource) 13-[2011-03-01 10:38:59Z] Verbose(0) Created operation named Cancel with signature ThingHandler::Cancel(Int32 id) 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor OperationFilterContributor.ProcessOperations 13-[2011-03-01 10:38:59Z] Verbose(0) Found 1 operation(s) with a matching name. 13-[2011-03-01 10:38:59Z] Verbose(0) Found 1 operation(s) with matching [HttpOperation] attribute. 13-[2011-03-01 10:38:59Z] Verbose(0) No resource or no uri name. Not filtering. A first chance exception of type 'System.FormatException' occurred in mscorlib.dll A first chance exception of type 'System.FormatException' occurred in mscorlib.dll A first chance exception of type 'System.Exception' occurred in System.dll A first chance exception of type 'System.NotSupportedException' occurred in OpenRasta.DLL A first chance exception of type 'System.FormatException' occurred in mscorlib.dll A first chance exception of type 'System.FormatException' occurred in mscorlib.dll A first chance exception of type 'System.Exception' occurred in System.dll A first chance exception of type 'System.NotSupportedException' occurred in OpenRasta.DLL 13-[2011-03-01 10:38:59Z] Error(0) None of the operations had members that could be matches against the uri parameters: id=Thing; 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Verbose(0) Pipeline is in RenderNow mode. 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor OperationResultInvokerContributor.RunOperationResult 13-[2011-03-01 10:38:59Z] Information(0) Executing OperationResult OperationResult: type=MethodNotAllowed, statusCode=405. 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor ResponseEntityCodecResolverContributor.FindResponseCodec 13-[2011-03-01 10:38:59Z] Information(0) No response codec was searched for. The response entity is null or a response codec is already set. 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor DigestAuthorizerContributor.WriteCredentialRequest 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Start(1) Entering PipelineRunner: Executing contributor ResponseEntityWriterContributor.WriteResponse 13-[2011-03-01 10:38:59Z] Verbose(0) There was no response entity, not rendering. 13-[2011-03-01 10:38:59Z] Verbose(0) Writing http headers. 13-[2011-03-01 10:38:59Z] Stop(1) Exiting PipelineRunner 13-[2011-03-01 10:38:59Z] Information(0) Pipeline finished.
任何人在那里能够帮助我?
干杯
戴夫
如果您可以添加一个调试日志,让我们知道POSTing时实际发生了什么。 – SerialSeb 2011-02-25 14:26:49