title: Get original request url in WCF REST service
body: <p>I've to retrieve the orginal request url in my WCF rest webservice. Now my code looks like this:</p>
  
  <pre><code>public class MyServiceAuthorizationManager : ServiceAuthorizationManager
  {
      protected override bool CheckAccessCore(OperationContext operationContext)
      {
          base.CheckAccessCore(operationContext);
  
          var url = operationContext.IncomingMessageProperties.Via.OriginalString;
          ...
  </code></pre>
  
  <p>web.config</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;
        &lt;standardEndpoints&gt; 
           &lt;webHttpEndpoint&gt;
               &lt;standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/&gt;
        &lt;/webHttpEndpoint&gt;
      &lt;/standardEndpoints&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>if my original url is</p>
  
  <p><strong><a href="http://192.168.1.100:8081/test" rel="noreferrer">http://192.168.1.100:8081/test</a></strong></p>
  
  <p>this code return</p>
  
  <p><strong><a href="http://hostname:8081/test" rel="noreferrer">http://hostname:8081/test</a></strong></p>
  
  <p>is there a way to retrieve the exact original request url?</p>
  
  <p><strong>Note</strong></p>
  
  <p>I found posts talking about cutomize "baseAddress" tag in web.config but I've no specific endpoint fom my extensionles webservice and I don't want to add it. I don't know if there is a way to do it without endpoint.</p>
  
  <p>I found this post
  <a href="https://stackoverflow.com/a/5915713/735864">https://stackoverflow.com/a/5915713/735864</a> plays with System.Net.HttpRequestHeader.Host but with port number it doesn't works! I know I can parse provided url and do a Replace but... I don't think this is the best practice to achieve this.</p>