开发者

Overriding the Default WCF REST 4.0 helppage

I've been trying to find a way to override the default WVF REST 4.0 helppage with my own one, and came across this post:

http://code.msdn.microsoft.com/WCF-Custom-Help-Page-6f5a90f0

I've been trying to use the same approach in an IIS hosted service using the following code:

namespace WcfHelpRestService
{
    public class Global : HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes();
        }

        private void RegisterRoutes()
        {
            // Edit the base address of Service1 by replacing the "Service1" string below
            var factory = new MyServiceHostFactory();

            RouteTable.Rou开发者_开发百科tes.Add(new ServiceRoute("Service1", factory, typeof(Service1)));
        }
    }
}

namespace WcfHelpRestService
{
    public class MyServiceHostFactory : WebServiceHostFactory
    {
        public MyServiceHostFactory ()
        {

        }
        protected override System.ServiceModel.ServiceHost CreateServiceHost(Type             serviceType, Uri[] baseAddresses)
        {
            return new MyServiceHost(serviceType, baseAddresses);
        }
    }
}

namespace WcfHelpRestService
{
    public class MyServiceHost : WebServiceHost
    {
        public MyServiceHost(Type serviceType, Uri[] baseAddresses): base(serviceType,  baseAddresses)   
        {

        }
        public override void AddServiceEndpoint(System.ServiceModel.Description.ServiceEndpoint endpoint)
        {
            endpoint.Behaviors.Add(new HelpPageEndpointBehavior("ACME LLC"));
            base.AddServiceEndpoint(endpoint);
        }
    }
}

however I keep getting the error:

[AddressAlreadyInUseException: HTTP could not register URL http://+:51443/Service1/help/ because TCP port 51443 is being used by another application.]

System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() +1106

not quite sure what I'm doing wrong, so any help would be greatly appreciated.

TIA

Søren


Looks like this address is exclusively locked by some other application.

This could be in case :

  • when you are using same address for some other application.
  • when you have started same app twice with same address
  • when IIS 5.1 is used that is locking exclusively port in your case 51443.

From above, look like third one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜