Well, this looks much same as you see. In English, Website is a sort of a Web Application. But from the developer’s perspective, the Web Application project type and the Website Project Type have many differences. If you are a Visual Studio 2005 user, You will not get Web Application Project type if you have not installed Service Pack 1.

There are four major differences of each as they are highlighted.

1) Visual Studio Project File

A Web Application stores information about the project such like the list of files available and the references that the project has included. This is under the extension of .csproj or .vbproj depending on the language used for coding. A Website does not contain such information file and it just list all the files in the folder structure into a site.

It is easy to temporarily remove files from the site but still make sure that you do not lose track of them, because they remain in the folder structure. For example, if a page is not ready to be deployed, you can temporarily exclude it from the build without deleting it from the folder structure. You can deploy the compiled assembly, and then include the file in the project again. This is especially important if you are working with a source control repository. Therefore the Web Applications does suppose to be better than the website at this point as the only difference is availability to copy and paste without compiling in websites. Compiling does not take that much of a time. So Web Applications ROX…

2) Point of Compilation

A Website has its code in a special App_Code directory and it’s compiled into several assemblies(DLL) at run-time. A Web Application is pre-compiled into one single Assembly.

Compiling in advance makes sure that users do not have to wait while the site compiles on the production server. (If the site is very large, dynamic compilation of a Web site project might take a noticeable amount of time. Dynamic compilation occurs when a request for a site resource is received after an update to the site, and the request that triggers compilation might be delayed while the required resources are compiled.

In other ways, Website makes the ease of testing without waiting for the changes of the dependent files. Therefore, I would prefer websites for a small scale application and if needed to be changed the source frequently as you cannot change the entire source at once and test. If it is a website, small parts of the website can be changed easily. So, there are still advantages using websites.

3) Explicit Namespaces

In a Web Application, explicit namespaces are added to pages, controls, and classes by default. But in a website you need to add them manually.

4) Deployment on Server

A Website can be either copied directly or pre-compile and put the set of files into the destination. In Web Applications, you will have to compile and publish the application assemblies that will be running on the IIS server. There is a rich support for compilation of Web Applications in Visual Studio but less likely to be for Websites.

Here we have the security conformance. If you are using a web application, it is 100% sure that your source code is not exploited to who ever the person do even hack the server. Form developer’s perspective, you can demand the source code for a higher amount as you still provide the functionality without it.

,

ASP.NET provides you a greater set of capabilities for working with a proper authentication. This is made available with the Membership Provider in it. Membership provider provides rich set of features including adding new users and assigning them specific roles.

By default, once you create an ASP.NET Application (Not empty application), it provides the capability of registering the users and sign-in them. But, how does this work, where are these registration data are stored? As soon as you create an application, just check the folder structure by browsing it through Windows Explorer. (In Visual Studio: Right-click on Application->Open Folder in Windows Explorer) Go inside the App_Data folder and you will find nothing inside in it.

Go back to Visual Studio and Run the application. Then create a new user account (Register). Once you are done, re-check the App_Data folder. You will find a database and a log file created named ASPNETDB. This is the file created for storing the user information by default. You can see a new connection string is made in Web.config file.

So, the Database name remains as ASPNETDB. But we do need to have a different name which has a relevance to our application. Basically, this database includes a set of tables and views. We can add them into our own database or a new database with a name which we would like to have. ASP.NET SQL Server Setup Wizard provides this opportunity. This tool is located in “[drive:]\%windir%\Microsoft.NET\Framework\version” folder of the file system. Once you get in there, open the aspnet_regsql application.

You can either Configure SQL Server for application services or Remove application services from an existing database. Once you get it done, you will have the required tables and fields in the database you want.

Assigning Roles to Users

A user can have many roles. A role defines something that a particular user needs to have. For example as user may need to have access to Health Department and the Transport Department. In such a scenario, what we can do is create two Roles for Health and Transport Departments and assign the user to both. When we are rendering the views or executing the methods, we can restrict by User Role. But, how are we gonna have this Role feature?

Visual Studio provides a tool named ASP.NET Configuration for this. You can find it in the Solution Explorer. It is a tool with a web interface. It will be browsed with the parameter applicationPhysicalPath in your web browser. Just go to the Security tab and click on the link Enable Roles. There you can view the Existing Users as well as you can create User accounts from there.

Once you Enable the Roles, you can create the roles and assign users to the system through this tool. Also you can have all those features in your web application it self. Lets discuss them in another article.

The web.config file will get changed once you change the Enable Roles feature and all the roles you create will be stored in the database.

<roleManager enabled="true">
      <providers>
        <clear />
        <add connectionStringName="ApplicationServices" applicationName="/"
          name="AspNetSqlRoleProvider"
          type="System.Web.Security.SqlRoleProvider" />
        <add applicationName="/" name="AspNetWindowsTokenRoleProvider"
          type="System.Web.Security.WindowsTokenRoleProvider" />
      </providers>
    </roleManager>

In MVC, the controllers can have the attribute [Authorize(Roles="Health")] like such and restrict the users by accessing them.

, ,