The Web Site project is compiled on the fly. You end up with a lot more DLL files, which can be a pain. It also gives problems when you have pages or controls in one directory that need to reference pages and controls in another directory since the other directory may not be compiled into the code yet. Another problem can be in publishing.
If Visual Studio isn't told to re-use the same names constantly, it will come up with new names for the DLL files generated by pages all the time. That can lead to having several close copies of DLL files containing the same class name,
which will generate plenty of errors. The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be popular.
The Web Application Project was created as an add-in and now exists as part
of SP 1 for Visual Studio 2005. The main differences are the Web Application Project
was designed to work similarly to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build
time. To update the project, it must be recompiled and the DLL file
published for changes to occur.
Another nice feature of the Web Application
project is it's much easier to exclude files from the project view. In the
Web Site project, each file that you exclude is renamed with an excluded
keyword in the filename. In the Web Application Project, the project just
keeps track of which files to include/exclude from the project view without
renaming them, making things much tidier.
The article ASP.NET 2.0 - Web Site vs Web Application project also gives reasons on why to use one and not the other. Here is an excerpt of it:
- You need to migrate large Visual Studio .NET 2003 applications to VS
2005? use the Web Application project.
- You want to open and edit any directory as a Web project without
creating a project file? use Web Site
- You need to add pre-build and post-build steps during compilation?
use Web Application project.
- You need to build a Web application using multiple Web
projects? use the Web Application project.
- You want to generate one assembly for each page? use the Web Site project.
- You prefer dynamic compilation and working on pages without building
entire site on each page view? use Web
- You prefer single-page code model to code-behind model? use Web Site
Web Application Projects versus Web Site Projects (MSDN) explains the differences between the web site and web application projects. Also, it discusses the configuration to be made in Visual Studio.
This solution will give you programmatic access to the controls in their entirety including all attributes on the controls. Also, only the text box values will appear in the URL upon submission so your GET request URL will be more "meaningful"
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JonSkeetForm.aspx.cs" Inherits="JonSkeetForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<title>Jon Skeet's Form Page</title>
<form action="JonSkeetForm.aspx" method="get">
<input type="text" ID="text1" runat="server" />
<input type="text" ID="text2" runat="server" />
<asp:Repeater ID="Repeater1" runat="server">
Then in your code-behind you can do everything you need on PageLoad
public partial class JonSkeetForm : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
text1.Value = Request.QueryString[text1.ClientID];
text2.Value = Request.QueryString[text2.ClientID];
If you don't want a form that has
runat="server", then you should use HTML controls. It's easier to work with for your purposes. Just use regular HTML tags and put
runat="server" and give them an ID. Then you can access them programmatically and code without a
The only downside is that you won't have access to many of the "helpful" ASP.NET server controls like
GridViews. I included a
Repeater in my example because I'm assuming that you want to have the fields on the same page as the results and (to my knowledge) a
Repeater is the only DataBound control that will run without a
runat="server" attribute in the Form tag.