HttpRequest.Host.Url resolving to something different than the domain name of the request - possible culprits?

I have an ASP.NET application running on a web host. There is some logic that is calling on


to dynamically construct some URLs for use in anchor tags. On my local dev environemnt, the result is as expected, namely "localhost" for Host.Url.

However, on the production server, it is not as I would expect. The URL of the page I am loading looks like:

The logic that uses HttpRequest.Url.Host is building some links for the page, and the result is actually:

What could cause this? I was under the impression that HttpRequest.Url.Host was based on the http request headers, which in the case of the page load is the basic

If the webhost used some sort of proxy server to re-direct the request (as opposed to the DNS resloving directly to the responsible ASP.NET server), would that result in this problem? Or could it be something else?

-------------Problems Reply------------

I have observed similar behavior but I don't understand well why .NET/IIS is handling the request in such a strange way. Another interesting test is to use Request.Url.ToString() which will report one address and then use string.Replace() (or another string method) which will report a different address.

It seems to be related to DNS records (environment settings in general).

I believe what Request.Url.Host is portraying is whatever reverse DNS the TCP stack of your client happened to come across. The same thing happens if I ping; I get Pinging [] with 32 bytes of data.... Not the same host.

If you want the exact host name that was typed into the browser's address bar, use the HTTP Host header: Request.Headers["Host"]

Note that Request.Headers["Host"] will include a port number if present in the address bar, so if you're expecting the host name only, use Request.Headers["Host"].Split(':')[0]. Views:0 Time:2011-03-14

Related post

  • Does Ivy's url resolver support transitive retrieval? 2010-05-19

    For some reason I can't seem to resolve the dependencies of my dependencies when using a url resolver to specify a repository's location. However, when using the ibiblio resolver, I am able to retrieve them. For example: <!-- Ivy File --> <i

  • How to access HttpRequest from in Django 1.2 2011-09-01

    I need to do the same thing asked in How to access HttpRequest from in Django but using version 1.2. Sorry, is what I have. I don't want to clutter the, so the two solutions given are not valid for me :) Thank you very much for your t

  • https urls on subdomain redirect back to main domain url 2012-01-21

    I have a subdomain, If I try to access it redirects back to I do NOT want secure urls to redirect back to the main domain. I believe this is controlled by a simple .htaccess rule but I don't know whe

  • Error "An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to reach a DNS server that can resolve DNS names in the target domain." 2012-09-16

    Original title: Help Me please When trying to add a new Windows 7 machine to a network I get the following error message..."An attempt to resolve the DNS name of a DC in the domain being joined has failed. Please verify this client is configured to r

  • How to resolve print spooler services problem in domain 2008 2012-11-09

    How to resolve print spooler services problem in domain 2008 --------------Solutions------------- The Windows Server gurus hang out in the Windows Server forums, best to ask these kinds of questions there:

  • An attempt to resolve the DNS name of a domain controller in the domain being joined has failed. 2013-03-31

    We had windows Server 2008 Enterprise domain controller. we want to Join Client PC Which had installed windows 7 professional 64bit. but gives me error message "An attempt to resolve the DNS name of a domian controller in the domain being joined has

  • Video Url Resolver for dailymotion and 2010-08-09

    I'm stuck in getting the direct link of the video file on dailymotion and website. Ex: direct video url of http: // is http: //

  • Ivy custom url resolver 2010-08-30

    I am trying to create custom resolver in my ivysettings.xml file: <ivysettings> <settings defaultResolver="default"/> <resolvers> <chain name="default"> <url name="scala-tools"> <ivy pattern="

  • How to access HttpRequest from in Django 2011-01-29

    Basically I want to use a generic view that lists objects based on a username. Now, the question is, how do I do something like: (r'^resources/$', ListView.as_view( queryset=Resources.objects.filter(user=request.user.username), ... ) ) I couldn't fin

  • Setting the URL resolver directory when using a generated XHTML document? 2012-03-14

    Here's my current workflow: Load POJOs from the database. Pass them into Velocity, rendering a HTML template in-memory. Then render the outputted HTML to a PDF using Flying Saucer and iText. The problem occurs when I try to resolve relative URLs like

  • Stripes: all URLs resolved through StripesDispatcher and forwarded to pre-compiled JSPs 2008-10-16

    Is it possible to have the StripesDispatcher be the sole determiner of webserver urls by looking at the @UrlBinding annotations on action beans AND also having those action beans forward to pre-compiled JSPs / servlets WITHOUT needing to define and m

  • Django URL resolving infrastructure stops working 2010-05-27

    We recently launched a new Django-powered website, and we are experiencing the oddest bug: The site is running under Apache with mod_fastcgi. Everything works fine for a while, and then the URL tag and reverse() functionality stops working. Instead o

  • IE9 URL resolving problem when trying to send a filename as a parameter 2010-11-29

    I have to send a path of the xml configuration file to my swf using http params. URL looks as something like this: lw.local/m/swf/engine.swf?width=900&height=600&xml=/m/xml/stage.xml In Opera, Firefox, Chrome and Safari it works fine. However

  • How do I get Seam URLs resolved in the back end? 2011-05-18

    We've got the first of many pages that are going to be generated not by Seam but by FreeMarker. FreeMarker has no way to process an <s:link> but we need to have links within the page that link over to Seam pages within the same application. Wha

  • Need to have many different URLS resolve to a single web page 2012-02-13

    And I don't want to use GET params. Here are the details: the user has a bunch of photos, and each photo must be shown by itself and have a unuique URL of the form I create a unique URL for a user each time they a

  • Rails JQuery Mobile hash url resolve 2011-07-14

    i have a rails 3.0.7 app with jquery mobile 1.0b1. jquery mobile links make smooth transitions to f.e. "localhost/#user" when i make a direct request (or page refresh) to: "localhost:3000/#users" the server correctly gets a GET "/". after that i woul

  • URL Rewriting from a subdomain to main domain! 2010-04-19

    I am developing a pretty large website for a client, and its about 90% complete. It is currently hosted on a subdomain like so: now: when complete: My problem is that SO much of this site is linked to the tempor

  • how to make url in rails app that is not domain specific 2010-08-09

    I am making a dynamic URL in my rails app like http://localhost:3000?#{something}=#{something1} How do I get rid of the hardcoded domain name (localhost in this case). I want to deploy this app to heroku and heroku will give its own domain name. I do

  • jQuery - Get URL of iframe AFTER redirection on same domain 2010-09-12

    Using Jquery, how can I get the URL of an iframe after redirection has occurred to a URL in the same domain? --------------Solutions------------- The suggestion from sunn0 should work with this slight amendment. $("#iframeid").load(function(){ alert(

Copyright (C), All Rights Reserved.

processed in 0.235 (s). 11 q(s)