IIS web site with host name can't be accessed by IP address - asp.net-mvc-4

I have mvc 4 web api project set up on IIS giving host name as my computer name. When I call it by mycoumputername:portno, I can access my web api. But when I call it by myIPaddress:portno, I couldn't access it. But when I create new Site without giving host name as computer name, default as localhost, it can be access by IPaddress:portno. I can't find the reason. Anyway, I need to define hostname as my computer name to access from remote computers by www.mycomputername.com and also need to use IPAddress:portno for accessing from mobile.
Please help me, anyone. Thank you and appreciate your help.

The reason is the host name setting.
When you set a host name in IIS site binding you explicitly requires all requests to this site to contain the desired host header (read HTTP protocol for details).
When your browser accesses the site using the IP address, the requests won't contain the header to match your IIS side setting.
That's simply by design.

You just need to create a new binding in IIS for the domain without a host name and with the port number.

Related

DNS: Do i need to create a DNS entry to represent each of my web applications running in a same windows server under IIS?

Updated the question:
Assume that i run several web applications in one windows server under IIS. As you know, for the several web applications to co-exist in IIS, i need to differentiate them using a hostname, ip address or port combinations. Assuming that i go with defining a hostname binding unique for each of the web applications, do i need to create a DNS entry for the hostnames to be resolved?
There are three different sites i host in IIS in the same windows server. I can not allocate different ip address to each of my dev sites so i chose to use unique host names for each of the sites thus
api-orders.dev
api-catalog.dev
api-products.dev
etc..
api - indicates it is a web api.
orders | catalog | products - indicate it is an application serving a business department.
dev - indicates it is my development site.
My organization has several domains such as usdev.org.com, us.org.com, uk.dtt.org.com and more like.
Assuming that my Dev servers are hosted in the usdev.org.com domain. I should be able to request my hypothetical sites from within and also outside of the usdev.org.com domain
right now, when i use the below urls, i am not able to hit the site within or outside the domain. Not even from the web server where the sites are hosted. I ask this question to several people and could not get a clear response.
DO i need to create DNS entries corresponding to the hostname IIS binding of each site in order to solve this issue?
api-orders.dev.computer-name.domain.com
api-catalog.dev.computer-name.domain.com
api-products.dev.computer-name.domain.com
What kind of setup i need to acheive this?
If you just want to access the website via your Active directory. I think you shouldn't include servername in your domain name.
Because in common AD DNS Forward Lookup Zone.
You should have a primary zone called domain.com. Your web server will displayed as a HOST(A) Servername and its FQDN will be servername.domain.com.
Then you could create a CNAME api-orders.dev and map it to your servername.domain.com. The FQDN should be api-orders.dev.domain.com.
Finally you have to set the domain into IIS binding so that IIS can share 80 port for mutiple sites.
Since your cname api-orders.dev will not be considered as a seperate website, you have to input FQDN instead of CNAME.
If you want to access the website from internet, then you may need to purchase public domain from domain provider and map it to your server's public IP address.

Host name not working on IIS 8.5 when configuration are the same

Sorry in advance, this is my first post and I'm a novice with web hosting.
I have 2 websites hosted on the same IIS version 8.5 using a different application pool.
The problem is that I can't get Website A to connect outside the network whereas website B can connect just fine.
They have the same configuration except for the bindings.
I tried switching the port in the bindings from A to B and the problem still arises.
Example: https All Unassigned 25777 analytics.com (A) https all unassigned 25779 portal.com (B)
Since I was able to switch the port and portal still works, I'm assuming that the site configuration is fine and the port is fine.
I think the host name's problem.
How can I fix this?
The public IP was an issue.
The public IP provided by our ISP wasn't properly configured. Changing to a new one provided it by them allowed us to access the website from outside the network.

iis 8 not accepting ip address as hostname

We are trying to specify IP address instead of hostname(eg: www.abc.com) for WCF service hosted in IIS v8.0 on windows server 2012
This gives error saying special characters not allowed. Is this not allowed?
But it works fine when we specify IP address as host name in our local systems which runs IIS v7.5.
A hostname is not an IP address, therefore you can't specify it in the site bindings as a host name.
If you are trying to access a service on your local IIS machine, simply having the site binding present is enough, but you may want to bind it to a specific IP address (the IP address dropdown), or if you leave it as "All Unassigned" then the application will be available on all IPs registered with the server, on your chosen port.
If you are trying to access an app on another machine from yours, you can either get a DNS value added by your network admin, or change your HOSTS file (C:\windows\system32\drivers\etc\HOSTS) and add in your own alias:
54.XXX.XXX.XXX myalias
Which means you should then be able to access http://myalias:8092/ from your browser.
Update The validation message is apparently by design:
http://blogs.msdn.com/b/dasane/archive/2013/10/16/adding-ip-address-like-host-head-in-iis-8-shows-ui-validation-error-this-worked-fine-in-iis-7-5-and-earlier.aspx
Reading that article, I can now understand why you may want to use an IP address as a host-header, as it effectively allows you to route external IP address calls to your local machine without requirement of DNS changes. For what you need though, if the IP address is bound to an NIC on your local machine, just leave it blank as it will resolve locally anyway.
Check what you provided in Hosts file (C:\Windows\system32\drivers\etc folder) in your local machine
For the above case you need to provide the hostname not ip address

Silverlight Cross Domain exception when using IP Address

I have a strange issue where browsing to my Silverlight 5 website using the host name works perfectly fine but when using the IP address instead it throws this exception: http://iforce.co.nz/i/1ohkll5v.32o.png
I have implemented the clientaccesspolicy return stream in a REST service on my self hosted WCF web service (similar to Cross Domain Exception with WcfSvcHost), and it works perfectly fine when using the hostname. However if I debug that method it never actually gets called in the scenario with the IP address.
Is there some limitation in Silverlight that does not allow you to use the IP address with WCF? I seem to remember that this was working before some time ago.
Another reason of this error is that Silverlight prevents cross-zone acccess, too. Therefore, in the clinet browser, you need to add both addresses (the one with hostname and the one with IP address) to the same Security Zone (either Local Intranet or Trusted Sites) in Internet Explorer.
Although this is an old question—and it will not help you, it might help others.
I had the same issue and lost hours trying to find the answer. The problem for me—in the end—was that I was referencing the WCF service using the machine name. Because of this—Silverlight thought I was referring to a local machine—so Silverlight doesn't even bother making a client policy request.
So just reference the service using an IP address instead of the machine name. Even if that IP address is local. Then check with Fiddler and notice that the Silverlight client will now make a policy request before the first service call.

Access external url on web server

If I log in to our web server using RDP, I can't access any of the sites we run on that web server via their external url. For example, say my web server hosts www.example.com, when I log in to the web server, bring up a browser and try to go to www.example.com, I can't see it.
However, one of our sites was configured in some way to work like this, if I try to go to that url, it works as you might expect.
Unfortunately, this was done by our server hosting partners, who we are no longer in contact with. Does anyone know how this can be achieved?
You can do it in many way..
It depends on your network configuration, but it could also be a simple row in hosts file or a static dns record or a specific route for that ip address.
if you're using IIS you should also set the website to "listen" on the loopback interface in the bindings menu.
or, for IIS 6: