关于此线程:404找不到我在Win 8.1-VS 2013-1上仍然存在此问题
<!--<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>-->
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" />
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<add path="*" name="ServiceStack.Factory" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
和
public class HelloAppHost : AppHostBase
{
/// <summary>
/// Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services.
/// </summary>
public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) { }
/// <summary>
/// Configure the container with the necessary routes for your ServiceStack application.
/// </summary>
/// <param name="container">The built-in IoC used with ServiceStack.</param>
public override void Configure(Container container)
{
//Register user-defined REST-ful urls. You can access the service at the url similar to the following.
//http://localhost/ServiceStack.Hello/servicestack/hello or http://localhost/ServiceStack.Hello/servicestack/hello/John%20Doe
//You can change /servicestack/ to a custom path in the web.config.
SetConfig(new HostConfig
{
HandlerFactoryPath = "api"
});
SetConfig(new HostConfig { DebugMode = true });
Routes
.Add<Hello>("/hello")
.Add<Hello>("/hello/{Name}");
}
}
当取消注释第二个system.webServer标记时,我仅从api路由获取HandlerNotFound异常。当我在web.config中删除位置标记时,会发生相同的错误。
就像现在一样,它可以工作...
感谢澄清的任何帮助,感谢诺伯特
您需要更改以下内容:
SetConfig(new HostConfig
{
HandlerFactoryPath = "api"
});
SetConfig(new HostConfig { DebugMode = true });
到
SetConfig(new HostConfig
{
HandlerFactoryPath = "/api",
DebugMode = true
};
只是一个猜测,但是您的HostConfig的第二个实例可能会覆盖第一个实例。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句