ServiceStack REST服务自定义路径错误
我在配置 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试以下操作:
1. 从 web.config 中删除位置节点。将 SS 配置移出其中。
2. 在从
AppHostBase
派生的类中注册基本 URL 路径: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
: