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

  • Home
  • SEARCH
  • 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 8712477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:07:06+00:00 2026-06-13T05:07:06+00:00

I have a simple WCF server that is using DuplexChannelFactory and named pipes. I

  • 0

I have a simple WCF server that is using DuplexChannelFactory and named pipes. I can call it from a console application and I can call it from a WPF application. However, is it possible to call the same WCF server from ASP.NET and still be able to call it from console\WPF app?

I am using the following endpoint:

[ServiceContract(SessionMode = SessionMode.Required,
  CallbackContract = typeof(IMyWCFClient))]
public interface IMyWCFServer
{
    [OperationContract]
    bool Subscribe();
    [OperationContract]
    bool UnSubscribe();
}

Can I update this to be callable from ASP.NET?

  • 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-06-13T05:07:07+00:00Added an answer on June 13, 2026 at 5:07 am

    Basically to create Ajax Enabled endpoint for your wcf service to have ability to call method from javascript you need to perform the following:

    1) Adds AspNetCompatibilityRequirements to your WCF service definition, so it will look like in the following code:

    namespace Test
    
    [ServiceContract(Namespace = "Test.Services")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class TestService : IMyWCFServer
    {
        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
    
        public bool UnSubscribe()
        {
            return true;
        }
    
        public bool Subscribe()
        {
            return false;
        }
    }
    

    Note: namespace is also vital, because it will be used by ScriptManager to generated client side proxy after service will be registered in it.

    2) Then adds [YourServiceName].svc file with the following definition to Asp.Net web application project:

    <%@ ServiceHost 
    Language="C#" Debug="true"
    Service="Test.TestService " 
    Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
    

    This file enough to register your WCF service as Ajax one.

    3) Then register this service with Script Manager by adding the following to pages (or Master page) where you want to use your service:

    <asp:ScriptManagerProxy runat="server" ID="ScriptManagerProxy">
        <Services>
            <asp:ServiceReference Path="~/[RelativePathToSVCFile].svc" />
        </Services>
    </asp:ScriptManagerProxy>
    

    Then you will be able to call your service from JavaScript like in the following example:

    var wasSubscribed = Test.Services.TestService.Subscribe();
    

    Some more information for example can be found in this article: http://dotnetslackers.com/articles/ajax/JSON-EnabledWCFServicesInASPNET35.aspx

    EDIT:
    There are several ways to add script references to script manager programmatically. The first one is ScriptManager control itself can be used too to register wcf service as script service. But to get current instance of script manager you will need reference to current Page Instance. So, the following code shows how this can be done from code behind class of any page or server control:

        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
            scriptManager.Services.Add(new ServiceReference { Path = "[RelativePathToSVCFile].svc" });
        }
    

    And this is example of how to add ScriptManagerProxy programmatically from code behind class of any page or server control. This approach requires that you have access to controls collection of the page or server control:

        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
    
            ScriptManagerProxy scriptManagerProxy = new ScriptManagerProxy { ID = "ScriptManagerProxy" };
            this.Controls.Add(scriptManagerProxy);
    
            scriptManagerProxy.Services.Add(new ServiceReference { Path = "[RelativePathToSVCFile].svc" });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple WCF service that I call server side from code behind
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I am trying to learn WCF. I have a simple client and server application
Hi I have built a simple WCF application I am using to query data
I have simple chat program using WCF service. One service use for server and
I have a simple app written using SQL Server, Entity Framework, C# and WCF.
I have a very simple wcf server. When a client uses an operation contract,
I have a simple WCF service hosted in IIS7 using the HTTP protocol. The
We have a simple WCF service that is tagged with InstanceContextMode = Single and
I have a very simple WCF service running that has a single method that

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.