Skip to content

Run servicestack side by side with another web framework

Arxisos edited this page Feb 28, 2012 · 6 revisions

In order to avoid conflicts with your existing ASP.NET web framework it is recommended to host your ServiceStack web services at a custom path. This will allow you to use ServiceStack together with an existing web framework e.g. ASP.NET MVC 3 or FUBU MVC, etc.

The location configuration below hosts your webservices at custom path: /servicestack

<location path="servicestack">
  <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" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
    </handlers>
  </system.webServer>
</location>

<!-- Required for MONO -->
<system.web>
  <httpHandlers>
    <add path="servicestack*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*"/>
  </httpHandlers>
</system.web>
<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
</system.webServer>

Note: Due to limitations in IIS 6 - the /custompath must end with .ashx, e.g: path="servicestack.ashx"

To avoid conflicts with ASP.NET MVC add an ignore rule in Global.asax RegisterRoutes method e.g: routes.IgnoreRoute ("servicestack/{*pathInfo}");

Clone this wiki locally