简体   繁体   English

使用IIS 6.0将C#项目添加到网站

[英]Add C# project to a web site using IIS 6.0

I just finished my first C# project in VS 2008 and it is working well now. 我刚刚在VS 2008中完成了我的第一个C#项目,现在运行良好。 But now I need to publish this project on my new website. 但是现在我需要将该项目发布到我的新网站上。 This project interacts with my SQL Server 2008 Adventureworks database on this same computer. 该项目与我在同一台计算机上的SQL Server 2008 Adventureworks数据库进行交互。 I am running IIS 6.0, but I am a newbie to both IIS 6.0 and VS 2008. 我正在运行IIS 6.0,但我还是IIS 6.0和VS 2008的新手。

I will use this same computer to host the website and house this database. 我将使用同一台计算机来托管网站并容纳该数据库。 I know HTML but not how to add a .NET project to a web site, especially one that also uses SQL Server. 我知道HTML,但不知道如何将.NET项目添加到网站,尤其是还使用SQL Server的网站。 Can u offer me tips as to how to proceed? 您能给我提示如何进行吗? This is not a Windows Form Application, so I am pretty sure it is a Web Application. 这不是Windows窗体应用程序,所以我很确定它是Web应用程序。

I started by right-clicking the project and selecting "Convert to Web Application" and then I selected the URL for my site. 首先,右键单击该项目,然后选择“转换为Web应用程序”,然后选择站点的URL。 But then when I went to this URL, it still shows the original image. 但是当我转到该URL时,它仍然显示原始图像。

Next I opened the IIS console window (Admin tool), but I didn't see an option to add a new website, so instead I opened the Properties window for Default website. 接下来,我打开了IIS控制台窗口(管理工具),但是没有看到添加新网站的选项,所以我打开了“默认网站”的“属性”窗口。 But even after changing the home directory here both to point to my project directory and also to point to my desired URL, when I refreshed my web browser it still shows same webpage from this URL. 但是,即使在这里更改了主目录后,它们既指向我的项目目录,又指向我想要的URL,但是当我刷新Web浏览器时,它仍然显示来自该URL的相同网页。 Do I have to close and reopen my web browser? 我必须关闭并重新打开网络浏览器吗? There are so many tabs and options in this IIS console window. 此IIS控制台窗口中有许多选项卡和选项。 Can you give me step-by-step instructions of what to choose? 您可以逐步告诉我如何选择吗? I also see many Property options in VS 2008 for this project. 我在VS 2008中也看到了该项目的许多Property选项。 Maybe I need to change something there? 也许我需要在那改变一些东西?

Did you create this C# project by using "New Web Site" or "New Project"? 您是否使用“新网站”或“新项目”创建了此C#项目?

If this is a web site, then when you right-click the "project", you'll see a "Publish Web Site" command. 如果这是一个网站,则在“项目”上单击鼠标右键时,您将看到“发布网站”命令。 Try that. 试试看

  1. In the dialog that pops up, there's a text box for the location. 在弹出的对话框中,该位置有一个文本框。 Click the "..." button. 点击“ ...”按钮。
  2. Choose "Local IIS" 选择“本地IIS”
  3. Navigate to where you want it, then click the "Create New Web Application" button in the tool bar. 导航至所需位置,然后在工具栏中单击“创建新的Web应用程序”按钮。
  4. Give the Web Application the name you want. 为Web应用程序指定所需的名称。
  5. Click "Open". 点击“打开”。
  6. Set the check boxes as you like. 根据需要设置复选框。 I suggest you check "Emit Debug Information". 我建议您检查“发出调试信息”。
  7. Click "OK" 点击“确定”

That's all there is to it. 这里的所有都是它的。

I'd recommend starting by setting the application up on the default site (localhost) and testing it there. 我建议首先在默认站点(本地主机)上设置应用程序并在其中进行测试。

To do this, 去做这个,

(Edited to work on IIS 6) (经编辑可在IIS 6上使用)

  1. Open IIS console (Administrative Tools -> IIS) 打开IIS控制台(管理工具-> IIS)
  2. Expand your computer name and then the "Web Sites" folder on the left hand tree 展开您的计算机名称,然后展开左侧树上的“网站”文件夹
  3. Right click on the "Default Web Site" and select "New -> Virtual Directory". 右键单击“默认网站”,然后选择“新建->虚拟目录”。
  4. Hit "Next" and type an alias (eg "myapp"). 点击“下一步”并输入一个别名(例如“ myapp”)。
  5. Hit "Next" and browse to point the path to your application directory. 点击“下一步”并浏览以指向应用程序目录的路径。 Make sure it is pointing to the folder that contains the web application, not the solution folder if you have multiple projects. 如果您有多个项目,请确保它指向包含Web应用程序的文件夹,而不是解决方案文件夹。
  6. Hit "Next" and check "Read" and "Run scripts". 点击“下一步”并检查“阅读”和“运行脚本”。
  7. Hit "Next" and "Finish". 点击“下一步”和“完成”。
  8. Navigate to http://localhost/myapp to test. 导航到http:// localhost / myapp进行测试。

(above assumes you already have the .net framework installed) (以上假设您已经安装了.net框架)

The process for setting up a public website is similar, but you choose "New -> Web Site" from the "Web Sites" folder in step 3, and the interface that pops up will request a host header too. 设置公共网站的过程类似,但是在步骤3中,从“网站”文件夹中选择“新建->网站”,弹出的界面也会请求主机头。 For info on host headers, dns, etc. you should look on serverfault.com. 有关主机头,dns等的信息,请查看serverfault.com。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM