-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Run servicestack side by side with another web framework
This page has moved to docs.servicestack.net
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 (to your root Web.config file) below hosts your webservices at custom path: /api
<configuration>
<!-- ... -->
<location path="api">
<system.web>
<httpHandlers>
<add path="*" type="ServiceStack.HttpHandlerFactory, 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.HttpHandlerFactory, ServiceStack"
verb="*" preCondition="integratedMode"
resourceType="Unspecified" allowPathInfo="true" />
</handlers>
</system.webServer>
</location>
<!-- ... -->
</configuration>
Configuration for also running on Mono / IIS 6:
<!-- Required for MONO -->
<configuration>
<!-- ... -->
<system.web>
<httpHandlers>
<add path="api*" type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*"/>
</httpHandlers>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<!-- ... -->
</configuration>
Note: Due to limitations in IIS 6 - the
/custompath
must end with.ashx
, e.g:path="api.ashx"
You also need to configure the root path in your AppHost.
public override void Configure(Container container)
{
SetConfig(new HostConfig { HandlerFactoryPath = "api" });
}
To avoid conflicts with ASP.NET MVC add an ignore rule in Global.asax RegisterRoutes
method e.g: routes.IgnoreRoute ("api/{*pathInfo}");
For MVC4 applications you also need to unregister WebApi, by commenting out this line in Global.asax.cs
:
//WebApiConfig.Register(GlobalConfiguration.Configuration);
Note: If you used Nuget to install the bits, remove the original handler from the web.config system.webserver node e.g:
<add path="*" name="ServiceStack.Factory"
type="ServiceStack.HttpHandlerFactory, ServiceStack" verb="*"
preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />
Due to Mono bug you need to set up explicitly ASP.NET auth to 'windows' mode when using ServiceStack auth on Mono, otherwise auth will be always redirected to /login.aspx insted of getting nice 401 (invalid username or password) response.
Add to web.config
under system.web
section.
<!-- Required to use ServiceStack auth under Mono -->
<authentication mode="Windows" />
- Why ServiceStack?
- Important role of DTOs
- What is a message based web service?
- Advantages of message based web services
- Why remote services should use separate DTOs
-
Getting Started
-
Designing APIs
-
Reference
-
Clients
-
Formats
-
View Engines 4. Razor & Markdown Razor
-
Hosts
-
Security
-
Advanced
- Configuration options
- Access HTTP specific features in services
- Logging
- Serialization/deserialization
- Request/response filters
- Filter attributes
- Concurrency Model
- Built-in profiling
- Form Hijacking Prevention
- Auto-Mapping
- HTTP Utils
- Dump Utils
- Virtual File System
- Config API
- Physical Project Structure
- Modularizing Services
- MVC Integration
- ServiceStack Integration
- Embedded Native Desktop Apps
- Auto Batched Requests
- Versioning
- Multitenancy
-
Caching
-
HTTP Caching 1. CacheResponse Attribute 2. Cache Aware Clients
-
Auto Query
-
AutoQuery Data 1. AutoQuery Memory 2. AutoQuery Service 3. AutoQuery DynamoDB
-
Server Events
-
Service Gateway
-
Encrypted Messaging
-
Plugins
-
Tests
-
ServiceStackVS
-
Other Languages
-
Amazon Web Services
-
Deployment
-
Install 3rd Party Products
-
Use Cases
-
Performance
-
Other Products
-
Future