ServiceStack REST服务自定义路径错误

发布于 2025-01-06 11:26:59 字数 1527 浏览 0 评论 0原文

我在配置 ServiceStack REST 服务以使其在生产 IIS 7.5 机器上运行时遇到问题。它在本地主机上运行良好,如果我部署在“默认网站”的根目录 - /EmployeeSvc 中,它也可以正常运行。为了组织目的,我在默认网站下有一个虚拟目录结构(注意 web.config 中的自定义路径)。我可以成功浏览到此位置的 default.htm,但是当我尝试执行内置 /hello 示例时,我收到:

服务器错误 404 - 未找到文件或目录。 您正在查找的资源可能已被删除、名称已更改或暂时不可用。

正如我所说,内置 /hello 示例可以在 localhost 和默认网站下的根 iis 文件夹中完美运行,但不能在目录结构中运行。我的位置路径做错了什么?

提前致谢!这是 web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <location path="Employees-NoAuth/WebServices/EmployeeSvc">
        <system.web>
          <httpHandlers>
            <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
          </httpHandlers>
        </system.web>

        <!-- Required for IIS 7.0 -->
        <system.webServer>
          <modules runAllManagedModulesForAllRequests="true"/>
          <validation validateIntegratedModeConfiguration="false" />
          <handlers>
            <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" verb="*" />
          </handlers>
        </system.webServer>
  </location>

  <system.web>
    <customErrors mode="RemoteOnly"/>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

</configuration>

I am having trouble configuring my ServiceStack REST service to work on my production IIS 7.5 box. It works fine running localhost, and it also works fine if I deploy in the root of "Default Web Site" - /EmployeeSvc. I have a virtual directory structure under Default Web Site for organizational purposes (note custom path in web.config). I can browse successfully to the default.htm at this location, but when I try to execute the built-in /hello example I receive:

Server Error 404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Like I said, the built-in /hello example works perfectly from localhost and from a root iis folder under default web site, but not from within a directory structure. What am I doing wrong with the location-path?

Thanks in advance! Here is web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <location path="Employees-NoAuth/WebServices/EmployeeSvc">
        <system.web>
          <httpHandlers>
            <add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" />
          </httpHandlers>
        </system.web>

        <!-- Required for IIS 7.0 -->
        <system.webServer>
          <modules runAllManagedModulesForAllRequests="true"/>
          <validation validateIntegratedModeConfiguration="false" />
          <handlers>
            <add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" verb="*" />
          </handlers>
        </system.webServer>
  </location>

  <system.web>
    <customErrors mode="RemoteOnly"/>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

</configuration>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若能看破又如何 2025-01-13 11:26:59

我会尝试以下操作:
1. 从 web.config 中删除位置节点。将 SS 配置移出其中。
2. 在从 AppHostBase 派生的类中注册基本 URL 路径:

public override void Configure(Container container)
{
    this.SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "base/path" });
}

I'd try the following:
1. Remove location node from web.config. Move SS configuration out of it.
2. Register base URL path in your class derived from AppHostBase:

public override void Configure(Container container)
{
    this.SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "base/path" });
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文