前提
小編最近在學習JQuery的一些内容,誰曾想上來的第一個Demo就把小編難住了,需要将本地html頁面上文本框中的内容上傳到伺服器上,然後将伺服器上的内容傳回。而小編将檔案放到IIS的預設網站上,本以為很簡單,可是發現小編沒有預設網站。而且在位址欄中輸入localhost,提示錯誤404,。也許是手欠吧,不知道何時把預設網站删除了,這個可怎麼辦?各種嘗試,最終找回了預設網站,解決了localhost無法登陸的問題。
解決方案
這個前提是建立在安裝好iis的基礎上的,在C:》Windows》System32》Drivers》etc中有一個hosts檔案,選擇文本格式打開就行了。将下述内容複制到其中。
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
注意下預設網站的端口為圖中的樣子,對于這個localhost規定就是這樣的沒有什麼理由可言,按規矩做就可以了。然後重新開機計算機完美解決。
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiI0gTMx81dsQWZ4lmZf1GLlpXazVmcvwFciV2dsQXYtJ3bm9CX9s2RkBnVHFmb1clWvB3MaVnRtp1XlBXe0xCMy81dvRWYoNHLwEzX5xCMx8FesU2cfdGLwMzX0xiRGZkRGZ0Xy9GbvNGLpZTY1EmMZVDUSFTU4VFRR9Fd4VGdsYTMfVmepNHLrJXYtJXZ0F2dvwVZnFWbp1zczV2YvJHctM3cv1Ce-cGcq5iN2YzN5kzN3kzYyUWM1MTZyYzXyADMyETM5IzLcdDMyIDMy8CXn9Gbi9CXzV2Zh1WavwVbvNmLvR3YxUjLyM3Lc9CX6MHc0RHaiojIsJye.jpg)