Generate a publish file in VS
Now that you have a website, you can publish it. You can publish a Web site to any location that you can access by using any of the connection agreements that Visual Studio supports. There are several ways to copy a Web site:
Copy to a folder on the local computer.
Use a UNC share to replicate to a shared folder on another computer on the network.
Use FTP to copy to the server.
Use the HTTP protocol to replicate to a server that has the FrontPage Server Extensions (FPSE) installed.
In this part of the walkthrough, you will publish the Web site to a local folder.
Publishing Web Sites
On the Build menu, click Publish Web site.
The Publish Web Site dialog box appears.
In the Target Location box, enter C:\CompiledSite.
Warning |
All data in the destination folder and its subfolders will be deleted. |
For this walkthrough, you will publish to a local folder. If you want to publish to a remote Web site using HTTP or FTP, you need to specify the URL of the remote server in the target Location box.
Clear "Allow this precompiled site to be updated."
This option specifies that all program code is compiled into an assembly, but pages and user controls (. aspx,. ascx, and. master files) are copied to the destination folder as-is, and can be updated as a text file without precompiling the project. in this walkthrough, you will not select this option. For more information, see ASP. NET site project Deployment Overview.
Click OK.
Visual Studio precompiled the content of the Web site and writes the output to the specified folder. The Output window displays progress messages. If an error occurs at compile time, the error is reported in the Output window.
If an error occurs during the publishing process, fix the errors, and then repeat the process.
Check the output of the Publish Web site command
It is useful to see the output of the Publish Web site command so you can see what Visual Studio does with your Web site files.
Check the output of the Publish Web site command
-
-
Open with a text editor such as Notepad SamplePage.aspx file.
Note that the original tag is not included in the file. instead, the. aspx page is just a placeholder that can be used as part of the URL.
-
move to the Bin folder.
-
.compiled file, corresponding to the page.
-
.dll files, such as the class file that you created, Contains the executable code for the Web site.
The page, page code, and individual class files that you created have been compiled into executable code.
Test the published Web site
You can now test the site by running the published Web site.
Set up IIS for the server
Create an IIS virtual directory that points to the destination folder.
From the Windows Start menu, choose Run, enter Inetmgr, and then click OK.
The Internet Information Services (IIS) Manager dialog box appears.
In the Connections pane, expand the server name, and then expand Sites.
Right-click Default Web site, and then select Add Virtual directory.
The Add Virtual Directory dialog box appears.
In the Alias box, enter Compiledwebsite.
In the Physical Path box, enter C:\CompiledWebSite.
Click OK.
In IIS Manager, in the Connections pane, right-click the new virtual directory, and then select Convert to Application.
The Add Application dialog box appears.
Click OK.
Open the browser and type the following URL:
Http://localhost/CompiledSite/SamplePage.aspx
The SamplePage.aspx page appears. However, this time you are looking at the version of the page that the precompiled compiler created for deployment.
Next steps
This walkthrough demonstrates the basic process of publishing a precompiled Web site. areas for further study include:
Try using the Copy Web Site tool instead, which copies the site as-is (by source) to the destination folder. For more information, see Deploying Web Site projects by using the Copy Web Site tool.
Publish the Web site to a remote IIS Web site.
C#-vs Publishing Web site