title: Get original url without non-standard port (C#)
body: <p><strong>First question!</strong></p>
  
  <hr>
  
  <p><strong>Environment</strong></p>
  
  <p>MVC, C#, AppHarbor.</p>
  
  <p><strong>Problem</strong></p>
  
  <p>I am calling an openid provider, and generating an absolute callback url based on the domain. </p>
  
  <p>On my local machine, this works fine if I hit <code>http://localhost:12345/login</code></p>
  
  <pre><code>Request.Url; //gives me `http://localhost:12345/callback`
  </code></pre>
  
  <p>However, on AppHarbor where I'm deploying, because they are using non-standard ports, even if I'm hitting it at "<a href="http://sub.example.com/login" rel="nofollow noreferrer">http://sub.example.com/login</a>" </p>
  
  <pre><code>Request.Url; //gives me http://sub.example.com:15232/callback
  </code></pre>
  
  <p>And this screws up my callback, because the port number wasn't in the original source url!</p>
  
  <p>I've tried</p>
  
  <ul>
  <li>Request.Url</li>
  <li>Request.Url.OriginalString</li>
  <li>Request.RawUrl</li>
  </ul>
  
  <p>All gives me "<a href="http://sub.example.com:15232/callback" rel="nofollow noreferrer">http://sub.example.com:15232/callback</a>".</p>
  
  <p>Also to clear up that this isn't a Realm issue, the error message I am getting from DotNetOpenAuth is </p>
  
  <pre><code>'http://sub.example.com:14107/accounts/openidcallback' not under realm 'http://*.example.com/'. 
  </code></pre>
  
  <p>I don't think I've stuffed that up?</p>
  
  <p>Now, I'm about to consider some hacky stuff like </p>
  
  <ul>
  <li>preprocessor commands (#IF DEBUG THEN PUT PORT)</li>
  <li>string replace (Request.URL.Contains("localhost"))</li>
  </ul>
  
  <p>All of these are not 100% solutions, but I'm sick of mulling over what could be a simple property that I am missing. I have also read <a href="https://stackoverflow.com/questions/40680/how-do-i-get-the-full-url-of-the-page-i-am-on-in-c">this</a> but that doesn't seem to have an accepted answer (and is more about the path rather than the authority). So I'm putting it towards you guys.</p>
  
  <p><strong>Summary</strong></p>
  
  <p>So if I had <code>http://localhost:12345/login</code>, I need to get <code>http://localhost:12345/callback</code> from the Request context.</p>
  
  <p>And if I had "<a href="http://sub.example.com/login" rel="nofollow noreferrer">http://sub.example.com/login</a>", I should get "<a href="http://sub.example.com/callback" rel="nofollow noreferrer">http://sub.example.com/callback</a>", regardless of what port it is on.</p>
  
  <p>Thanks! (Sleep time, will answer any questions in the morning)</p>