views:

914

answers:

2

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?

+2  A: 

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.

John Saunders
Oh, I clicked "New Project". Is it possible to still change this to a new web site? How would I do that? Or how could I move the files over otherwise?
salvationishere
No, you don't want to. You've got it right. I just thought you'd done a web site. There's also a publish for Web Application Projects. Try that.
John Saunders
BTW, I've confirmed that Publish for a web application project works almost the same as Publish Web Site works. Just slightly different options.
John Saunders
John, I did this but when I got to step 3 it says: "The Web Site 'AddFileToSQL' is not marked as an application in IIS. Do you want to open it anyway?"
salvationishere
I opened it anyway and when I published this I included all files from App_Data folder. Target location for this is now http://192.168.2.2/AddFileToSQL/. But when I enter this URL into the Browser address field, it reverts back to URL http://sqlmagic.net/.
salvationishere
Which step 3? Mine doesn't have an open.
John Saunders
John, I meant step 5. I don't see the same options that u described in steps 1-7. I checked and it is actually IIS 6.
salvationishere
+1  A: 

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 (e.g. "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.

Joel Potter
There is no "Sites" folder. There is a Web Sites folder though; do u mean this? And when I right click Default Web Site there is no option to "Add Application". Remember this is IIS 7.0; are u thinking of IIS 6.0?
salvationishere
What's your operating system? Vista or Server 08? On my Vista box, those are the names and menu options.
Joel Potter
It's Windows XP
salvationishere
I don't think IIS 7 installs on XP. Check your version. You're probably on 6.
Joel Potter
Updated for IIS 6.
Joel Potter
Joel, to clarify. I checked and I am on snap-in 5.1. So I downloaded IIS 6.0 Manager now. But this doesn't have "Site" option either. I also ran the IIS 6.0 migration tool. But this didn't have it either. What do I need to download?
salvationishere
Joe, I just now see that u edited your steps. Thank you. I followed your steps above but when I test it it does not display. I think the reason is earlier I tinkered around with some of the Default Web Site properties. Like what should it be set to in the Home Directory tab? Web Site tab? Documents tab?
salvationishere
Make sure default.aspx is added to the default documents list. Also make sure you have the asp.net extension enabled under web server extensions. Some general setup info: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/fc473b0b-162b-4146-932c-2a9a50c52ecb.mspx?mfr=true
Joel Potter
Thanks Joel, it's getting late here; I'll try this tomorrow morning and comment back.
salvationishere
There is too much for me to look at in that link to do right now. I will try this this afternoon. Thanks.
salvationishere
Joel,I reviewed all of this general setup info and here is what I did. I copied the DLL to the C:\Inetpub\wwwroot\[MyApp]\bin directory. And I copied the web.config, global.asax, and default.aspx files to the C:\Inetpub\wwwroot\[MyApp] directory. Only difference is that the name of my application is "AddFileToSQL", but name I gave this folder under C:\Inetpub\wwwroot\ was "AFS". Does this matter? When I navigate to http://192.168.2.2, it still shows default web page. However when I go to http://192.168.2.2/AddFileToSQL, it prompts me to enter password. Which password and is this right?
salvationishere
Make sure you have enabled anonymous access (it's in the properties, I believe under security) and that the iis user has access to the wwwroot folder (should by default). I believe the iis user on xp was called iuser_computername, but you can find out for sure by going into application pools and looking at what account is being used by the "default app pool".
Joel Potter
Joel, I tried all of your suggestions but it is giving me HTTP 403 error. And I have tried all of the different options for Directory Security in the Properties window. Anything else you can think of to diagnose cause? Or any other MS URL's u are aware of that might be helpful? Thanks!
salvationishere
403 is generally permissions related. Make sure the app pool user has read access to the wwwroot/afs folder. In iis go to Application Pools -> DefaultAppPool -> Properties -> Identity. The app pool will either be using a predefined or configurable account. Either way make a note of which account and add that account to the afs folder you created earlier.
Joel Potter
Joel, I do not see Application Pools in IIS. All I see is Web Sites, FTP Sites, and Default SMTP Virtual Server.
salvationishere
I just setup an XP vpc with iis6 so I can better see what you are seeing. From the looks of it, iis6 in XP doesn't treat pooling the same as server 2k3. Try this: on the Home Directory tab set Application Protection = Low (IIS Process), and on the Directory Security tab click the top Edit button and make sure Anonymous access is checked and that the Username entered (IUSR_COMPUTER by default) has read privileges on the afs folder.
Joel Potter
Thank you for going to all this trouble, Joel, to test! I went to the Virtual Directory tab and set Application Protection = Low. And on Directory Security tab I did what you said. Then I right-clicked on my project in IIS and selected Browse. When I do this, it displays a page that says "192.168.2.2 - /AFS/" where AFS=name of my web application. underneath this it says "Parent directory" with a URL link to my app. But when I click on this link it again says HTTP 500 error. Can u reproduce this to see what I am seeing?
salvationishere
Sounds like you're browsing the folder rather than running the app. Try going to 192.168.2.2/afs/default.aspx. If that works, than go to the documents tab in properties and add default.aspx to the list. If not, than you probably need to install the framework.
Joel Potter
No, this didn't work either. I added to machine.config, processModel the attribute: userName="D610-M\ASPNET" password="AutoGenerate"But then when I go to Browse this website from IIS6 it pops up a login/password box. And since I don't know ASPNET built-in password, I can't open the website. I've also tried creating a new website from VS pointing to http://localhost/AFS, but this didn't work either cause I didn't know password. And I have tried substituting other userNames in machine.config file. And I added ASPNET user read/write/list permissions to all of the relevant folders.
salvationishere
Joel, I'm reentering this question to sum up everything I've done. Please see my newest question.
salvationishere