Click here to Skip to main content
15,885,754 members
Articles / Web Development / ASP.NET
Article

Create a .NET Web Project

Rate me:
Please Sign up or sign in to vote.
2.74/5 (11 votes)
11 Oct 20065 min read 49.9K   18   2
This article describes how to create a .NET web project.

Introduction

This article describes how to create an ASPX project in such a way that the source code is easily managed and distributed. It is aimed at developers writing applications for use on a corporate intranet, though it would be equally appropriate for other scenarios.

Background

When creating a Visual Studio project, it is important that all the project files are stored in a single location from where it can be backed up, copied to a live server, or just copied to be reused. I recently helped a junior programmer create an ASP.NET project. While showing him the ropes, I realised how overwhelming it can be the first time.

Here is a description of what VS does when you create a new project, and how you can manipulate the files to make the project more manageable.

Procedure

Once you have opened VS.NET, go to File - New - Project.

Image 1

For "Project Type", select "Visual C# Projects", and for "Template", select "ASP.NET Web Application". For "Location:", change only the name of the application (not the location itself, i.e., "http://localhost/Test_App").

Image 2

VS will now create a solution with the same name as your project as well as your project and also list it in IIS (Internet Information Services). In the “Solution Explorer” pane you can see your application with “Webform1.aspx” selected. We are going to make this form our home page (the first page that opens when you navigate to this application). In the “Properties” pane, change the Form name to something like "Test_App_Index.aspx" - Save the solution and close VS.

VS now saves your application under the default web location: “C:\Inetpub\wwwroot\Test_App”, but the solution file is saved in the VS default project directory. In my case: “My Documents\Visual Studio Projects” The location of this default directory can be found in VS under “Tools - Options” Then “Environment - Projects & Solutions”.

Image 3

This is where our problems start:

  • We now have a web application saved under “Inetpub\wwwroot” and thus listed in IIS. This means that your application is now available via a web browser.
  • We have a solution file that is not saved in the same directory as the application..
What we want to do is to group all the relevant files of our project together in a location where we have better control over our application’s web presence.

The first thing we want to do is to copy our project folder to a location convenient to us. To do this, in Windows Explorer go to "C:\Inetpub\wwwroot" and find your project folder (Test_App). Copy it to the desired location and rename the folder if you like. In order to keep things organised, it is advisable to create a root folder (Test_App) and a subfolder (Interface) that will contain the User interface documents (i.e., everything that was in "C:\Inetpub\wwwroot\Test_App").

Image 4

My file structure now looks like this:

Image 5

The next step is to remove the initial instance of our project from IIS and replace it with the one in the directory we have just created.

So open IIS and delete the project. (IIS can be found by right clicking on “My Computer” and then selecting “Manage”. IIS is located at the bottom under “Services & Applications”.) This will also delete the project from "C:\Inetpub\wwwroot". Close IIS.

Image 6

In Windows Explorer, go to our folder and “web share” it. You can use any name, but then you will have to edit the project file, so rather just stick with the name you used right in the beginning (“Test_App”).

Note

The folder you want to share is the folder containing the project files, not the root folder. In my case “Interface” and not “Test_App”. Remember that my folder structure looks like this: “C:\Test_App\Interface”.

Image 7

In Windows Explorer, navigate to the VS project folder. (Remember the path to this directory can be found in VS under "Tools/options/Projects & Solutions".) Mine is in “My Documents\Visual Studio Projects”. Delete the project folder (“Test_App”) from the "Visual Studio Projects" directory. This will delete the Solution that was automatically created by VS when we first saved the project.

Image 8

Open IIS again. You will see that our project is listed here again. This is because we “Web shared” the containing folder. Right click on our project and select “Properties”. On the "Virtual Directory" tab, “Remove” and then “Create” the "Application name:".

Image 9

Now go to the "Documents" tab and remove all documents from the list, and add only your default page name ("Test_App_Index.aspx").

Image 10

Note

If you are going to capture the user's network ID (Windows user name) you also have to go to the "Directory Security" tab, click "Edit" and remove the "Anonymous access" tick at the top of this tab. At the bottom of the same tab, make sure "Integrated Windows authentication" is ticked.

In Windows Explorer, navigate to your project folder. Double click the ".csproj" file to open the project in VS. This will again create a solution, but in the current directory.

Image 11

In VS, in the “Solution Explorer” pane, right click the web form “Test_App_Index.aspx” and select “Set As Start Page”. Save the Solution by clicking on the "Save All" icon (Toolbar Left top) Or press Ctrl+Shif+S.

Image 12

In future when you want to open the project, double click the “.sln” file in order to open the whole solution in VS.

Image 13

There you have it! You now have all your project files together in one known location. If you need to add any other files to your project (like graphics or existing .html or .aspx pages) you can copy them to this location and then add them to your project/solution. This way you keep everything neat and manageable.

History

  • Posted - 10 Oct 2006.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralInteresting article Pin
rajantawate1(http//www.tawateventures.com12-Oct-06 2:14
rajantawate1(http//www.tawateventures.com12-Oct-06 2:14 
GeneralGood article - wish I'd seen it a year ago Pin
StockportJambo11-Oct-06 19:51
StockportJambo11-Oct-06 19:51 
This is something that foxed me for about a day and a half after I first started web development in .NET in my last job (previously only having developed WinForms apps). It was slightly embarassing at the time, but there's not much documentation out there that isn't buried in a lot of other (irrelevant to the basic job at hand) stuff.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.