Using the MVC Routing Engine when self hosting (from a dll)?

Topics: Web Api
Nov 9, 2011 at 5:54 PM

I'm using WCF Web API to create a self-hosted/InProcess REST Service (HttpServiceHost) that the client app will use. All the examples for the web api use ASP.Net routing engine. Would it be possible to use the routing engine outside of Asp.net?

To give you an idea what i'm doing, here is the contructor of my Service Class that the client will new up:

    Public Sub New()

        ObjectFactory.Initialize(Sub(x)
                                     x.For(Of IIssueTrackerRepository)().Use(Of IssueTrackerRepository)().Ctor(Of String).Is(ConfigurationManager.ConnectionStrings("Dev").ConnectionString)
                                     'x.ForConcreteType(Of IssueTrackerResource)().Configure.Ctor(Of String).Is(ConfigurationManager.ConnectionStrings("Dev").ConnectionString)
                                 End Sub
        )

        _host = New HttpServiceHost(ObjectFactory.GetInstance(Of IssueTrackerResource), "http://localhost:8000")
        _host.Open()
    End Sub

Coordinator
Nov 9, 2011 at 6:04 PM

Currently ASP.NET Routing only works in Web host, although we are investigating creating a unified routing story for web-host and self-host. On Preview 5 you will need to use UriTemplates and manage the service base address yourself.

Daniel Roth

Nov 9, 2011 at 7:02 PM

Thanks Daniel