Scenario: I have an ASP.NET MVC application developed in Visual Studio 2008. There is a root folder named "Content" that stores images and stylesheets. When I run locally (using Cassini) and browse my application, every resource from the "Content" directory is always downloaded. Using Firebug, I can verify that the web server returns an HTTP 200 ("ok").
Desired: I would like for Cassini to return HTTP 304 ("not modified") instead of 200. This is the behavior when running the site under IIS7.
Reasoning: The site I am working on has a large number of static resources (often as many as 40 per page). Browsing the site is very fast on IIS7, because these resources are (correctly) cached by the browser. However, browsing the site on my local machine is painfully slow.
Pages that render in under 1 second on IIS7 take over 30 seconds to render on Cassini. It's actually faster for me to upload the entire website every few minutes and test from there. (Yes, I recognize that this is perverse and crazy.)
So: how can I instruct/trick Cassini into treating the "Content" directory like IIS7 does?
Are you sure the problem is caching? Because the content does get cached correctly on my machine when I run the application on Cassini.
I think the problem you're having could be Firefox's under-performance with resolving IPv6 addresses, which causes a very annoying delay on loads with addresses like http://localhost:55555.
What I did to change this behaviour was to change the network.dns.disableIPv6 preference on about:config to true on Firefox. I suggest trying that.
I've had a similar problem in Chrome. To resolve this uncomment the IPv4 localhost line in you hosts file. Apparently these are commented by default in Windows 7.
127.0.0.1 localhost
#::1 localhost
Another option for you is to simply skip Cassini and debug under IIS. It's pretty straightforward, and won't take you ten minutes to get up and running. Browse 20 of your pages on Cassini, and you've used that time anyway ;)
One thing I've noticed isn't always in the guides, is that if you want to debug on a different address than http://localhost/ you need to manually set the host to your local IIS. This is done by adding a line in the hosts file, located at
C:\Windows\system32\drivers\etc\hosts
Open the file with notepad (you need to "Run as Administrator" in order to be able to save if you're using Windows Vista and have User Account Control turned on...) and add your host. For example, to debug under http://mysite/ you add
mysite 127.0.0.1
Related
I have a few different PHP sites running on local domains (i.e. domains set to 127.0.0.1 in /etc/hosts) so I can work on them without any network delay.
I'd like to be able to work on these sites when I have no connection at all (e.g. on the bus or in the park) but my browser (Firefox on LinuxMint) can't load the local pages when there's no network connection (it doesn't have to have Internet access, but it must have a working network connection). Note that it can load a site via local IP addresses or "localhost", but not using any other local domain name.
I'd like to create some kind of local network that makes the Network Manager show a valid connection even when there is no LAN adapter present. Or alternatively a way to make Firefox work with the local domains without needing the network would be just as good.
Reproduce this problem as follows:
- Run a local web-server such as micro_httpd and serve a test site
- Set up some other names for 127.0.0.1 in addition to localhost in your /etc/hosts file such as foo.bar
- Test that your site works from localhost and from foo.bar
- Unplug your network cable
- Test again, only localhost works, not foo.bar
- Test with wget, both work fine
I have the same issue. Either of these work for me, in Firefox go to about:config and click I'll be careful, I promise!, search for network.dns then either:
Set network.dns.disableIPv6 to false
or
Add your local domain names to network.dns.localDomains
I think the latter is probably the better of the two options, but either works for me.
Adding a little to Lee Kowalkowski answer:
I have modified below at admin:config in my firefox developer edition 61.0b3 (64-bit)
network.dns.localDomains added localhost as I bind my local sites with localhost
I haven't needed this functionality for a couple years and noticed now as of Firefox 60 that there is no problem any more.
This old Bugzilla thread mentions the issue and says it was resolved by adding the about:config key network.dns.offline-localhost, perhaps that's set to true by default now which is why it works?
This issue is occurring in a C#, .NET 4.0 environment. I tried using Fiddler but it doesn't show up. After searching around, the suggested solution was to change the address of the request from localhost to the machine-name.
This worked on my local machine: after changing the call from localhost to my-machine, fiddler picked it up. The real issue is on a client's staging environment with production code. I can not modify the code there to take this change.
Note, as far as I know, on the client site it should be making the request out to the host name and not localhost anyways.
Also, on my local machine I actually hit localhost in my browser, and it seems to pick those up fine. Just not the request built in code. Why is that?
Thanks!
It sounds like you're saying: "This works fine on the client's PC but not on my dev PC when using Localhost." Is that correct?
In IE9, I changed WinINET to enable Fiddler to capture loopback traffic from the browser. Sadly, the .NET Framework hasn't yet adopted support for the <-loopback> token, which means that traffic sent to 127.0.0.1 or localhost bypasses the proxy.
So I'm trying to install a local server to experiment on... Tried Wamp which gave this problem in the title (or so I thought).
Instead, I then tried installing Apache, and Xampp. Everything seems fine again. But when I type http://localhost into my browser (firefox, but for what it's worth the same thing happens with IE) it just redirects me to http://anonym.to/.
Anyone know why?
That's some kind of anonymizer site that acts as a proxy server to browse anonymously. You should probably check your /etc/hosts file to see if there is a redirect going on there for localhost or 127.0.0.1.
Either you have an entry in your Windows Hosts file %SystemRoot%\system32\drivers\etc\hosts (entry which you can delete by editing this file) or your browser has proxy settings set (which you can unset).
I have some pages on my local machine, accessed via localhost, that are horribly slow to open/load using IE8, but very fast using Firefox, Opera, Chrome and Safari.
They used to load really quickly using IE7.
I produced a cut down page to test - to see what was causing the problem - and seriously, the most simple page possible causes it! I.e:
<html>
<head></head>
<body>
Hello!
</body>
</html>
Takes about 15 seconds to open on localhost in IE8, and is instant on all other browsers! Why? What can I do to resolve this?
By the way, tried this on a Web server, connecting via a URL via IE8, and it was basically instant when opened via IE8 via the Web/Web server!
I have Windows Update enabled, so should have the latest of everything.
Note: I only noticed this after my internet connection changed, which was about 2 weeks after IE8 was installed. Possibly that is coincidence, it MAY have started with the install of IE8, I am actually not sure. It is definitely happening now though.
The URL I am using is: http://localhost/fb/starttest.htm
Help!
Try the following:
1- Navigate to C:\Windows\System32\drivers\etc
2- Open the file hosts using any text editor
3- Add this line to the end of the file
127.0.0.1 localhost
4- Before you save this file, you need to make sure that any program that access the internet (browsers etc.) is closed - Save the file and test it
Under Tools -> Internet Options -> Connections -> LAN Settings, is the box "Automatically detect proxy servers" checked?
If so, that does a DNS request to wpad.(domain search suffix) to discover proxy servers via their Auto Discovery Protocol.
If nothing responds, the query will have to timeout before it gives up.
I also had this exact same problem recently - 'localhost' taking 15 seconds to load, but 127.0.0.1 loading instantly.
However, I have now fully solved my problem, so I write here in the hope that it will help someone.
My problem coincided with the purchase of a D-Link DIR-655 wireless router, so after trying many of the kindly offered 'fixes' on this forum, I turned back to my router settings in search of an answer.
I eventually discovered a setting on the SETUP - NETWORK SETTINGS page. The 'Enable DNS Relay' box was checked, so I read about it, and it apparently allows the router to lookup DNS addresses from the ISP's server. This is obviously not desired for a 'local' address on my own PC, and so I tried unticking it.... and HEY PRESTO, IT WORKED!!!
I hope this work for some of you, too!
All the best,
Rob
I have exactly the same problem as you do, except I'm using IE7 (IE takes about 16 seconds to load localhost, while Firefox and Google Chrome loads it in an instant).
I don't have the autodiscovery for proxy checked either.
I also tried starting IE without add-ons (From Accessories->System Tools) and it didn't make a difference.
I found out that using 127.0.0.1 instead of localhost greatly improved the speed (like 2 seconds instead of 16 seconds!). However, I edited hosts file and I left only the line
127.0.0.1 localhost
and this didn't fix the problem. Need to dig some further.
Regards,
Nicolae
I have a Default Web Site and another web application (let's call it Application2) inside the Default Web Site in IIS7.
I have 2 registered domain names, let's say www.example.com and www.example.net.
I would like to configure things that when I open www.example.com I get Default Web Site, when I open www.example.net I get Default Web Site/Application2.
www.example.com -> Default Web Site
www.example.net -> Default Web Site/Application2
How can I do that?
First you need to decide if your going to use Name Based or IP Based hosting.
IP-Based uses unique ip's to determine which virtual host it will serve and Name Based will actually use the host header which is sent by your client browser.
So let's see two scenarios:
Scenario # 1 (ONE IP TO SHARE)
You have a server with only one IP, could be either private or public as long as the domains you are serving are properly configured in the dns serving you internally or your client externally (NAT).
I suggest that for the sake of this tutorial you stop the default website. Ok.
You will set up one site in II7 and name it accordingly. Go to the right hand side of the manager and look for "Bindings" under actions menu; making sure you have the new site selected on your left pane. Now under "Site Bindings" select the ip address you will be sharing between the sites (name based hosting). Under "Hostname" enter domain # 1 "www.example.com", hit ok.
Follow the same procedure above with the other domain or domains, making sure they have diferent hostnames and same ip's.
That's it. You will now be able to start those sites and run them at the same time.
The same principle above applies if your using the "Default Site". "Default Site" is just a name MS gave the default created one.
Scenario # 2 (MULTIPLE IP TO SHARE)
If you have either some private or public ip to spare, or at least until you do the exercise the only diference here is that sites you will set up and don't have to specify the "Hostname" per each site, as this is basically done in the DNS zones itself. The sites will respond for any request made to those ip's on port 80 regardless.
When will you need to use multiple Ip's to serve websites. Well it all depends.
Some reasons are: Network Isolation (Security), Applications which don't work well under name based hosting, SSL Certificates Bindings 443(PRE II7), and mostly complete control over site. There are of course more reasons, but I'll let others write a bit also.
Have fun.
Edit... upon further investigation I found that if you can set up multiple sites and run them simultaneously. Just need to stop and start the sites after setting the host values to get them to both run at the same time.
Original post:
The straight-forward way to do this would be to add another application by opening IIS and right-clicking Sites then select Add Web Site. In there you can specify the physical path of Application2 and also set the "host" to "www.example.net" which will filter all those requests to your second site. Any requests that don't match "www.example.net" will still go to the default web site.
That approach will work fine on Windows Server using IIS, but on Vista's IIS7 it won't work since you can only have one site running at a time. To start the second site, you'd first have to stop Default Web Site.