-
Notifications
You must be signed in to change notification settings - Fork 0
Mvc integration
In the README.txt page when you install the ServiceStack.Host.Mvc NuGet package shows the instructions needed for installing ServiceStack with MVC, we've added an extra line for support with MVC4 since it comes bundled with a conflicting WepApi.
For MVC4 applications you also need to unregister WebApi, by commenting out this line:
//WebApiConfig.Register(GlobalConfiguration.Configuration);Hosting in ASP.NET MVC is very similar to hosting in any ASP.NET framework, i.e. The ServiceStack AppHost still needs to be initialized on start up in your Global.asax.cs (or WebActivator), e.g:
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
new AppHost().Init();
}
}You MUST register ServiceStacks /api path by adding the lines below to MvcApplication.RegisterRoutes(RouteCollection) in the Global.asax:
routes.IgnoreRoute("api/{*pathInfo}");
routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" }); Place them before the current entries the method.
For MVC4 applications you also need to unregister WebApi, by commenting out this line:
//WebApiConfig.Register(GlobalConfiguration.Configuration);ServiceStack automatically infers the handler path based on the <location> tag, if there's more than one in your Web.config or there is some other issue inferring it, it can be explicitly set in Config.ServiceStackHandlerFactoryPath, e.g:
SetConfig(new EndpointHostConfig {
ServiceStackHandlerFactoryPath = "api",
});To enable the Mini Profiler add the following lines in to MvcApplication in Global.asax.cs:
protected void Application_BeginRequest(object src, EventArgs e)
{
if (Request.IsLocal)
ServiceStack.MiniProfiler.Profiler.Start();
}
protected void Application_EndRequest(object src, EventArgs e)
{
ServiceStack.MiniProfiler.Profiler.Stop();
}For more info on the MiniProfiler see v3.09 of the https://github.com/ServiceStack/ServiceStack/wiki/Release-Notes
The Urls for metadata page and included Services:
- /api/metadata - Auto generated metadata pages
- /api/hello - Simple Hello World Service see: http://www.servicestack.net/ServiceStack.Hello/
- /api/todos - Simple REST Service see: http://www.servicestack.net/Backbone.Todos/
- /default.htm - Backbone.js TODO application talking to the TODO REST service at /api/todos
- Why ServiceStack?
- What is a message based web service?
- Advantages of message based web services
- Why remote services should use separate DTOs
- Getting Started
- 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 caching options
- Built-in profiling
- Form Hijacking Prevention
- Auto-Mapping
- HTTP Utils
- Virtual File System
- Config API
- Physical Project Structure
- Modularizing Services
- MVC Integration
- Plugins 3. Request logger 4. Swagger API
- Tests
- Other Languages
- Use Cases
- Performance
- How To
- Future