[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to ensure to always get domain name when using Url.Authority or Url.Host with Asp.Net

Posted on 2017-01-04
2
Medium Priority
?
40 Views
Last Modified: 2017-02-03
Microsoft's documentation states that it may return either the Host name or the IP address but it doesn't say how the framework determines which one to return. I'm having a problem in a production environment where Url.Authority returns the host name sometimes and at other times returns the IP address.

I need to ensure that it returns the host name every time. I've created a workaround for the moment but its not ideal, I need to figure out how to fix this.

I'm using the .NET Framework version 4.6.1 in all environments.
0
Comment
Question by:aiico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Dennis Aries earned 2000 total points
ID: 41948403
Basicly? You can't. The authority will return the part of the called URI and if that contains just the IP instead of the hostname, then the only option is to reverse lookup the ip to a hostname.

However, an IP-address can be mapped to multiple hostnames making this a dodgy practice unless you manage the DNS yourself.

DnsGetHostEntry can resolve the IP to hostnames but I assume you already use that as the mentioned workaround.

Dennis
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question