简体   繁体   中英

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. 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. I am running IIS 6.0, but I am a newbie to both IIS 6.0 and 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. 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.

I started by right-clicking the project and selecting "Convert to Web Application" and then I selected the URL for my site. But then when I went to this URL, it still shows the original image.

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. 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. Do I have to close and reopen my web browser? There are so many tabs and options in this IIS console window. Can you give me step-by-step instructions of what to choose? I also see many Property options in VS 2008 for this project. Maybe I need to change something there?

Did you create this C# project by using "New Web Site" or "New Project"?

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"
  3. Navigate to where you want it, then click the "Create New Web Application" button in the tool bar.
  4. Give the Web Application the name you want.
  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)

  1. Open IIS console (Administrative Tools -> 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").
  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.
  6. Hit "Next" and check "Read" and "Run scripts".
  7. Hit "Next" and "Finish".
  8. Navigate to http://localhost/myapp to test.

(above assumes you already have the .net framework installed)

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. For info on host headers, dns, etc. you should look on serverfault.com.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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