1
我一直試圖找到一種方法來替代默認退伍軍人會REST 4.0 helppage我自己一個,和整個此帖一:改變默認的WCF REST 4.0 helppage
http://code.msdn.microsoft.com/WCF-Custom-Help-Page-6f5a90f0
我已經一直在嘗試用同樣的方法在IIS託管服務使用下面的代碼:
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.Routes.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);
}
}
}
但我不斷收到錯誤:
[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
不太清楚我在做什麼錯,所以任何幫助將不勝感激。
TIA
瑟倫