Dela via


FTP-Deployed Web Sites

Visual Web Developer allows you to work with Web sites that you access using File Transfer Protocol (FTP). This makes it faster to work with sites that are hosted on another server, such as the server for a commercial hosting service.

What FTP Is

FTP is a standard protocol for copying files from one computer to another across the Internet. For example, many Web hosting sites allow users to copy files to the server using FTP.

An FTP server is similar to an HTTP server (that is, a Web server) in that you can communicate with it using an Internet protocol. However, an FTP server does not run Web pages; it only copies files to and from the server.

FTP Location versus Browse Location

It is typical that the server computer runs both an FTP server to support file transfers and a Web server to support HTTP access to files. These are separate servers even if they run on the same computer. Both of the servers map to the directory where the files are located.

Although the FTP server and Web server might be working with the same files in the same physical location (or directory), the URL for accessing the files is usually different for each of the protocols. For example, the URL for transferring files to a specific directory on the FTP server might be something like the following:

ftp://upload.contoso.com/fred/root/

In contrast, to run the files, you need a browse location, or the URL of a Web server that points to the same location. The browse location might look like the following:

http://contoso/fred/

Again, both of the URLs might be pointing at the same physical directory on the server.

FTP Web Sites in Visual Web Developer

In Visual Web Developer, an FTP Web site is simply a Web site that resides on a remote computer that you access using FTP. FTP access requires that you know the URL of the site. This is often provided as a complete URL (for example, ftp://servername/foldername). Under most circumstances, you also must have a valid user name and password to log on to the FTP server before being allowed to read or write files.

Once you have the FTP address of the site, you can open the site in Visual Web Developer. You can then edit and create files in the site as if they were local files. When you save the files, they are transferred via FTP to the server.

Active and Passive Mode

Visual Web Developer can establish connections to the FTP server in two modes: active mode and passive mode. In FTP, the client (in this case, Visual Web Developer) and the server communicate using two ports. One port is used to transmit commands, and the other is used to transmit data.

Active FTP benefits the server administrator. In active mode, the client initializes a connection to the server for the command port and passes to the server the port address for the data. The server then initializes a connection back to the client to open the data port.

Passive FTP benefits a client behind a firewall. If the client is behind a firewall, the server's attempt to open a port on the client computer will likely fail. In passive mode, the client initializes the connections for both the command port and the data port. Because the client initializes the connection for both ports, the firewall allows the connections.

For more information, see Information About the IIS File Transmission Protocol (FTP) Service.

Logon Credentials

Some FTP servers require that you pass authentication credentials to the server in order to connect. Visual Web Developer allows you to specify a user name and password when you establish a connection to the FTP server. If you specify credentials, they are cached in memory on your computer for the duration of your Visual Web Developer server. As a security measure, they are not stored on disk.

Note

If you do not provide the required credentials when specifying the logon information for the FTP Web site, Visual Web Developer prompts you for them when you attempt to connect. Visual Web Developer never attempts to connect to an FTP server anonymously unless you explicitly specify anonymous logon in the FTP Site Tab, Choose Location/Open Web Site Dialog Box.

The credentials are passed to the FTP server each time they are required. When you close Visual Web Developer, the credentials are discarded. The next time you establish a connection to the FTP server, you must specify the credentials again.

Typically, FTP credentials are passed as clear text and not encrypted for transmission. It is recommended that you use FTP with Anonymous or Basic authentication. For more information, see the topic "Authentication Methods Supported in IIS 6.0" in the IIS Technical Reference.

Creating FTP Web Sites

You can create FTP Web sites in Visual Web Developer the same way you create file-system sites or local IIS sites. However, because the site is being created on a remote server, you must have permissions to create a new folder. If you have an account on a hosted site, you generally cannot create new sites at the root level of your site, but you can usually create sites that are child sites of your root site. If you have questions about whether you have the necessary permissions to create new FTP sites, you should contact the administrator for the server.

Running FTP Web Sites in Visual Web Developer

You do not directly run an FTP Web site, since FTP is only a transfer protocol. Most commonly, the server computer runs both an FTP server to support file transfers and a Web server to support HTTP access to files.

In order for you see the Web pages from your FTP Web site in the browser, the server computer must have a browse location — that is, an HTTP URL that points to the same files as the FTP site. Although the FTP server and Web server might be working with the same files in the same physical location (directory), the URL for accessing the files is usually different for each of the protocols.

Check with the administrator of your site to determine the correct HTTP URL for the site. When you run an FTP Web site for the first time, Visual Web Developer prompts you for the HTTP URL of the site. The information is stored as part of the Web site in the startup options. For information, see Startup, Environment, Options Dialog Box.

Debugging FTP Web Sites

You can use the debugger with FTP Web sites as you would with other types of Web sites running on a remote server. Running the debugger with FTP Web sites — setting breakpoints, launching the debugger, and so on — is the same as it is for other Web sites. However, because the files to be debugged are on a remote site, you must configure the debugger to be able to attach to a remote process. For more information, see the "Remote Computer Configuration" section in Debugging Web Pages Overview.

Many commercial hosting sites do not support remote debugging. Contact the site administrator to find out whether you will be able to debug the site remotely.

Note

Remote debugging is not available in Visual Web Developer 2005 Express Edition.

Caching Files

When you work with an FTP Web site, Visual Web Developer caches files locally. The files and any dependent resources are read from the remote server and stored locally when you first access them. When you save a file, the file is saved locally and written to the FTP server. When you close a Web site, the cache is deleted. Under most circumstances, the fact that files are cached is transparent to you and to Visual Web Developer.

If two developers edit the same file at the same time, the changes from one developer might be overwritten. FTP-deployed Web sites cannot be integrated with a source control system.

See Also

Tasks

Walkthrough: Editing Web Sites with FTP in Visual Web Developer