【问题标题】:404 Not Found error when running ServiceStack on IIS8 Express在 IIS8 Express 上运行 ServiceStack 时出现 404 Not Found 错误
【发布时间】:2014-06-21 21:15:55
【问题描述】:

关于这个帖子:404 Not found 我在 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 中的位置标签时,会发生同样的错误。

就像现在一样,它可以工作......

任何澄清的帮助表示赞赏, 谢谢诺伯特

【问题讨论】:

    标签: servicestack


    【解决方案1】:

    您需要更改以下内容:

    SetConfig(new HostConfig
    {
        HandlerFactoryPath = "api"
    });
    SetConfig(new HostConfig { DebugMode = true });
    

    SetConfig(new HostConfig
    {
       HandlerFactoryPath = "/api",
       DebugMode = true
    };
    

    只是猜测,但您的第二个 HostConfig 实例可能会覆盖第一个。

    【讨论】:

      猜你喜欢
      • 2017-11-25
      • 1970-01-01
      • 2017-09-03
      • 2015-08-11
      • 1970-01-01
      • 2016-10-05
      • 1970-01-01
      • 2017-10-19
      • 2018-07-19
      相关资源
      最近更新 更多