Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local website renders differently using (IP address or machine name) vs localhost?

I have an MVC3 (razor) site published to IIS7 locally for testing purposes.

When I access the site via "localhost" it looks different from when I access using the IP address or machinename?

I have cleared my cache and re-loaded the pages to confirm and they still appear the different. The CSS must be loading to give the correct fonts/colours etc, although ":hover" elements appear to load much slower?

I am using JQuery/JQueryUI on the site if that helps identify the problem?

Localhost

IP Address

Any ideas?

Edit: More info

The titles, labels and table definition are build from ViewBag.Title, or looping through rows in a ViewModel - nothing clever, just standard MVC3/Razor stuff.

The same css file is used for every page, and F12 in IE8 shows the correct css has been loaded.

Title/subtitle font sizes/colours are correct, just their positioning is out? Table border appears thicker? Positioning generally seems a little "out", but I can't understand why there is this difference?

Can a firewall/AV package strip out positioning?

like image 854
BlueChippy Avatar asked Oct 11 '11 07:10

BlueChippy


People also ask

What is the difference between localhost and IP address?

Localhost is a hostname that refers to the local machine currently making the request. On many computers, localhost is an alias for the IP address 127.0. 0.1. When a computer pings this IP address, it is communicating with itself.

Should I use 127.0 0.1 or localhost?

On almost all networking systems, localhost uses the IP address 127.0. 0.1. That is the most commonly used IPv4 “loopback address” and it is reserved for that purpose.

What is the difference between loopback and localhost?

Localhost is an alias used to refer to IP addresses reserved for loopback. While IPv4 uses the last block of class A addresses (from 127.0. 0.1 to 127.255. 255), IPv6 reserves the first (0:0:0:0:0:0:0:1 - or : :1, in short) as its loopback address.

When should I use localhost?

What is localhost used for? Developers use the local host to test web applications and programs. Network administrators use the loopback to test network connections. Another use for the localhost is the host's file, where you can use the loopback to block malicious websites.


2 Answers

The same css file is used for every page, and F12 in IE8 shows the correct css has been loaded.

Developer Tools should show that IE is not using the same "Browser Mode"/"Document Mode" between the two instances of the site, because that's the problem here. IE defaults to different modes depending on if you're using a machine name or not (amongst other things).

Adding this to your <head> should sort out the problem:

<meta http-equiv="X-UA-Compatible" content="IE=edge">
like image 108
thirtydot Avatar answered Nov 02 '22 09:11

thirtydot


I had a similar issue, where the sizes differed from the local development site to the one on the production server. Turned out that I forgot the zoom level to 90% when viewing the development version... This answer helped me realize that: https://superuser.com/questions/315448/different-font-size-between-localhost-and-remote-server-in-firefox

like image 38
victorvartan Avatar answered Nov 02 '22 10:11

victorvartan