Saturday 20 July 2013

Diff between Website and Web Application in C#

Generally whenever we are trying to create new web project in visual studio we will fund two options ASP.NET Web Application and WebSite. What is the difference between these two which one we need to select to create project in asp.net?

It's choice of the people can go for web application or website we cannot say that which one is better because both is having advantages and disadvantages. Check below details for webaplication and website

Web Application

1. If we create any class files / functions those will be placed anywhere in the applications folder structure and it is precomplied into one single DLL.

2. In web application we have chance of select only one programming language during creation of project either C# or VB.NET.

3. Whenever we create Web Application those will automatically create project files (.csproj or .vbproj).

4. We need to pre-compile the site before deployment.

5. If we want to deploy web application project we need to deploy only .aspx pages there is no need to deploy code behind files because the pre-compiled dll will contains these details.

6. If we make small change in one page we need to re-compile the entire sites.

WebSite

1. If we create any class files/functions those will be placed in ASP.NET folder (App_Code folder) and it's compiled into several DLLs (assemblies) at runtime.

2. In website we can create pages in multi programming languages that means we can create one page code in C# and another page code in vb.net.

3. Web Sites won’t create any .csproj/.vbproj files in project

4. No need to recompile the site before deployment.

5. We need to deploy both .aspx file and code behind file.

6. If we make any code changes those files only will upload there is no need to re-compile entire site  




NOTE:
The basic difference between them is “Convert.ToString(variable)” handles NULL values even if variable value become null but “variable.ToString()” will not handle NULL values it will throw a NULL reference exception error. So as a good coding practice using “convert” is always safe.

Example

//Returns a null reference exception for str.
string str;
object i = null;
str = i.ToString();

//Returns an empty string for str and does not throw an exception. If you dont
string str;
object i = null;
str = Convert.ToString(i);

No comments:

Post a Comment