Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4554722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:07:30+00:00 2026-05-21T17:07:30+00:00

Bertrand created a blog post to specify how to use IoC in WCF Modules

  • 0

Bertrand created a blog post to specify how to use IoC in WCF Modules for Orchard.

In 1.1, you can create a SVC file using the new Orchard host factory:

<%@ ServiceHost Language="C#" Debug="true" 
    Service="MyModule.IMyService, MyAssembly"
    Factory="Orchard.Wcf.OrchardServiceHostFactory, Orchard.Framework" %>
Then register your service normally as an IDependency but with service and operation contract attributes:

using System.ServiceModel;

namespace MyModule {
    [ServiceContract]
    public interface IMyService : IDependency {
        [OperationContract]
        string GetUserEmail(string username);
    }
}

My question is that all of Orchard’s modules are really area’s. So how can you build a route that hits the svc file created in the area/module?

Should you use the full physical path to get to the svc file (tried that and it caused a web.config issue since it was bridging a site and area).

http://localhost/modules/WebServices/MyService.svc

Or do you create a ServiceRoute with WebServiceHostFactory/OrchardServiceHostFactory?

new ServiceRoute("WebServices/MyService", new OrchardServiceHostFactory(), typeof(MyService))

Whatever I try I get a 404 when trying to hit the resource. I was able to get this working using a wcf Application project and setting WCF as a stand alone application, my issues started when trying to bring it into Orchard/MVC.

UPDATE

Thanks for the help Piotr,

This is the steps I took to implement the service.

Routes.cs

new RouteDescriptor {   Priority = 20,
                        Route = new ServiceRoute(
                                      "Services",
                                      new WebServiceHostFactory(),
                                      typeof(MyService)) }

If I use OrchardServiceHostFactory() instead of WebServiceHostFactory() I get the following error.

Operation is not valid due to the current state of the object.

Orchard Root Web.Config

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

MyService

[ServiceContract]
public interface IMyService : IDependency
{
    [OperationContract]
    string GetTest();
}

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
class MyService : IMyService
{
    public string GetTest()
    {
        return "test";
    }
}

I couldn’t get the service working by just modifying the module’s web.config. I get the following error

ASP.NET routing integration feature requires ASP.NET compatibility.

UPDATE 2

Orchard Root Web.Config

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <!-- ... -->
  </system.serviceModel>

Routes.cs

public IEnumerable<RouteDescriptor> GetRoutes() {
    return new[] {
                     new RouteDescriptor {   Priority = 20,
                                             Route = new ServiceRoute(
                                                 "Services",
                                                 new OrchardServiceHostFactory(),
                                                 typeof(IMyService))

                     }
                 };
}

This works, the key here is that you must call typeof on the object that is referencing IDependency, WorkContextModule.IsClosingTypeOf cant handle the object that consumes the dependancy, it must take the Interface that it is directly called by.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:07:31+00:00Added an answer on May 21, 2026 at 5:07 pm

    As you stated, Orchard modules are areas in ASP.NET MVC terms, so the URL you provided is incorrect and should be:

    http://localhost/Your.Orchard.Module/WebServices/MyService.svc
    

    Where localhost is the virtual directory under which your app runs and /WebServices is a folder in the root of your module.

    You can also create a service route programatically without problem. This article tells how to add new routes in Orchard. You can just assign a ServiceRoute to the Route property of a RouteDescriptor instead of a default MVC route (as shown in docs).
    The question about adding ServiceRoute in area-enabled ASP.NET MVC app was asked before, check it out as it may help you out.

    Btw – You may also check this SO question about prefixed service routes.

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML file with values expressed in SI unit (m, N). I use
I came across a printed article by Bertrand Meyer where he states that tests
I have a C module which is created by the Real-time Workshop based on
You may think this question is like this question asked on StackOverflow earlier. But
I would like to know what are your practices when you test your classes.
I was reading Code Complete (2nd Edition), and came across a quote in the
I am new to Jquery and in learning phase. I have written a test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.