This blog is moved to www.dotnettwitter.com

This blog is moved to www.dotnettwitter.com

Advertisements

Web Application Vs Web Site in .NET

This post has been moved here

S.No Short Description Web Site Web Application
1 Road Map Introduced in VS 2005 only

Road Map:

VS 2003 .NET 1.1 (No Website Project Type)

VS 2005 – .NET 2.0 (Introduced Web Site by replacing Web application. After there are lots of request from the customer, Microsoft released a add-in for Web Application Project Type)

VS 2008 – .NET 3.5 (Both Web Site and Web Application Present)

VS 2010 – .NET 4.0 (Both Web Site and Web Application Present)

Introduced in VS 2003 itself

Road Map:

VS Version Web Site Web Application
VS 2003 No Yes
VS 2005 Yes No (Yes – by Add-in)
VS 2008 Yes Yes
VS 2010 Yes Yes
2 Project Definition The project will contain the same file and folder structure as Website created in the Virtual directory. So the Web site can have some files which are not part of the project (such as some requirement document, design document etc.). The solution will contain only the files which are referred/required to the project.

Adv:

  1. Not necessary to keep any files which are not required (all which are in Virtual directory)
  2. Can sub-divide one ASP.NET application into multiple VS project.
  3. Easily exclude or include the project from the source code-control
3 Compilation and build outputs The build comment is used for Web Site project only to test the project and not going to be used on runtime. To run the website we required to deploy the code on the web server and relay on ASP.NET dynamic compilation to compile the pages and classes in the application. All code-behind files and stand-alone classes in the project are compiled into a single assembly (Project Name.dll) and published (copied) in the Virtual directory. So there won’t be any dynamic compilation at run time.

As the output is a single assembly, we can specify attributes such as name, version, location etc.,

4 Interactive development We can setup the build option in VS how the build must be done when we run the site. Building the site can be in three ways: 1. Build the site 2. An individual page 3. Nothing at all.

If the nothing at all option is selected, the VS simply launch the browser and passes to the current/startup page.

To run and debug pages, we must build the entire project.

Adv: Building entire web application will make the development fast, because VS employs an incremental build model. It means the VS only build the files which are changed.

5 Deployment The Publish Website command will compile the aspx and code-behind files into assemblies in VS. But the default pre-compilation produces several assemblies in Bin folder on the site (typically assembly can be vary one per page, one per folder).

The Fixed-names option produces one per page (.aspx) or user control (.ascx). These can be used to create deployable version of individual page. But it will increase no of assemblies and increased memory usage.

As all code-behind and stand-alone class files are compiled into single assemblies, only the assembly needs to be deployed into the Web server along with .aspx, .ascx files and other static content files.

The .aspx, .ascx are not compiled until they run in the browser.

6 Upgraded from VS 2003 A conversation wizard is available to upgrade existing VS 2003 Web Application project to later version Web site project. There may be manual fix-up required if the project is much complex. As VS 2003 and later versions support Web application, no requirement to convert. So simple opening the project in later version of VS will do the job.
7 Deployment of the application Deploying the full source code on the server by copying both .aspx, .aspx.cs/.aspx.vb files to the server.
It is considered as XCOPY of the source code to the Web Server.
The source code will be compiled by ASP.NET runtime compiler on the Web Server before request is getting processed.
Adv: Enable to edit the code on the server itself to fix some bugs or to enhance the system.
Disadv: There won’t be security for the code, data and application functionality.
Compile the source code in the development environment and deploy the .aspx file and compiled .dll files to the server.
So copying the full source code with .aspx.cs /.aspx.vb files is not required.
The source code will be compiled in the Visual Studio at Development Environment before deployment to the server.
Adv: Security on code, data, application functionality.
Disadv: To change a simple buy entire deployment life cycle required to follow.
8 Unit Testing on Application It is difficult to create Unit Test cases (Ex: using MBUnit, Nunit, VS Unit Test project) by referring the actual source code of the Web Site. If it very easy to create Unit Test cases (Ex: using MBUnit, Nunit, VS Unit Test project) by referring the compiled DLLs. It will also be confirmed that the Unit Test will be done on a compiled code, so no changes will be done after testing completed.
9 Changes in Visual Studio 2005 Web Site has been introduced in VS 2005 only.
It makes available of all new features of VS 2005 and ASP.NET 2.0 (like master pages, site navigation, themes, web parts, personalization, role management, membership and loginetc.,)
Removed in VS 2005 release and replaced with Web Site project Type.
It removes (Web Site) two Web application requirements:
1. Using FrontPage Server Extension (FPSE)
2. Using a local copy of IIS (but website support both IIS and build-in ASP.NET development server).
10 Code behind Model Single Page code model. When we create a page, there will be a aspx.cs/aspx.vb file associates for the page.
We can even write the same code in the .aspx file also by writing inside of <script> tag.
Multiple page code models. When creating a page, there will be a aspx.cs/aspx.vb and aspx.designer.cs/aspx.designer.vb file created.
11 Code Compilation Code will be compiled dynamically when required (request has been raised from client) and on the required page.
It allows building particular page instead of entire site.
Adv:
1. Allows runtime changes (After a page viewed, the code behind can be changed and refreshed the changes on the page without breaking the entire application)
2. In Visual Studio – the developer can get the flexibility to edit the code on debugging mode. After saving the changes, the page can be refreshed to see the changes without rebuilding the website.
Full application code will be compiled on building the Web application and no further compilation on page request from the client system.
Disad: 1. In Visual Studio – the developer will not get flexibility to change the code (it will be locked – read-only) on debugging time. To change the code, the developer required to stop the application to change the code.
12 Assembly Naming The assembly name will be decided by the VS only. The assembly names can be controlled by developer. It means the assembly will be created on the bin folder; it can be renamed as per the developer view.
13 Assembly creation There will be one assembly for each page (including .aspx, .ascx etc.,) There will be a single assembly for a Web Application project (normally ProjectName.dll)
14 Building the application It can possible to build single Web project at a time and we will not have flexibility to add reference to any other Web Site project. As Web Application can be build using multiple web projects. So a Web Application can add reference to any other Web Application and use.
15 Building the application It is not possible to add Pre-built and Post-build steps during the compilation. It is possible to add Pre-built and Post-build steps during the compilation.

It means, we can add some command line steps on pre-build and post-build event by using Properties-> Build Event Tab.

16 Copy Web Site Menu Will have Copy Web Site menu on the Web Site to connect a remote Web Site and Copy/Synchronize the files between Source Web site and Remote Web site. There won’t be any Copy Web Site option to copy the files.
17 Compilation Constrains As the pages are compiled dynamically and compiled into different assemblies, there is no requirement that entire Web site must compile successfully to run the application.

If any error occurred on a page, it will throw the error at the time when the page getting compiling/running dynamically.

As entire pages are compiled at first time and created in a single assembly, the project must compile successfully.
18 Compatibility with Web Developer Express Edition Will work well Web application projects do not work with Visual Web Developer Express Edition.

Microsoft Introducing Sharepoint 2010

Microsoft® Introducing Sharepoint® 2010
Sharepoint 2010 is the business collaboration platform for the Enterprise & the Web that enables you to connect & empower people through an integrated set of rich features. Sharepoint 2010 enables to cut cost with a unified infrastructure whether it is deployed on-premises or as hosted services.
Sharepoint 2010 coming with lots of great features…. Some are listed below
  1. New User Interface – The new user interface with Ribbon gives an intuitive and contextual web user interface which makes users more effective, and provides better performance.
  2. Web Edit – The page also allows uses to edit and customize a site easily, which makes it possible to complete the task more quickly.
  3. Silverlight Web Part – The end user can experience with a rich media into the site using Silverlight Web Part. This also helps the developer to quickly develop and securely integrate Silverlight application.
  4. Rich Theming – Combined with Web Edit, rich theming allows skinning the site with favorite office client themes. It allows to customize the site by changing the colors and fonts to organization standards.
  5. Multiple Browser Support – Sharepoint 2010 allows you to experience the site in multiple browsers like IE, Firefox and Safari.
  6. SharePoint Designer – SharePoint Designer comes up with new UI, enhanced modeling capabilities and improved workflow capabilities which makes collaboration between designer and developer teams to work more creative and productivity.
  7. SharePoint Workspace – It was named as Groove – now comes as SharePoint Workspace, which takes the SharePoint list and libraries in to offline including with the ability to update content and sync it back in which the site gets re-connected.
  8. Business Connectivity Services – It is the evolution of the Business Data Catalog, which allows to connect to Line-of-Business applications, Web services and databases and surface the data in a user friendly way. It enabling the users to interact and update it easily in the web and in the office client.
  9. Visio Services – Visio Services allows to chare data linked diagrams in real time with a high-fidelity and interactive experience. So everyone can access consistent and up-to-date information, even those who don’t have Visio.
  10. Rich Media Support – The information and presentations comes to end user in a new and dynamic empowering and enriching the media support ways by Silverlight support or PowerPoint’s inline video editing capability etc.,
For more information please visit the SharePoint Site

What, Why and How Windows Azure 2009 Platform

What, Why and How Windows Azure 2009 Platform……
What
  • is an internet-scale cloud service platform hosted in Microsoft data center
  • a platform which provides operating system, a set of developer services that can be used individually or together.
  • a platform for running Windows applications and storing their data in the cloud.
  • a platform where all services (.NET Services, SQL Server, Live Services) installed which can be used by the applications
  • a platform where the code and/or data live in the cloud (internet), where somebody manages the system to use it
  • provides flexibility to run the application, store the data in the cloud or inside premise or both
  • there is a plan that Azure 2009 support unmanaged code as well i.e., the application are not built on .NET framework….. Its a great news.

Why (the benefits)

  • no buying, installing, operating cost (hosted on the cloud, and maintained by someone else)
  • pay just for the computing and storage use rather then maintaining a large set of servers
  • can control the behavior of the application in the cloud by changing the information in the config file
  • can create, configure, monitor application using a browser-accessible portal using Windows Live ID
  • provides capability to use/integrate existing on-promises web applications
  • provides multiple internet protocols HTTP, REST, SOAP, and XML.
  • provides ready for consumption such as Windows Live, Microsoft Dynamics, Microsoft Exahange Online, SharePoint Online etc.

Cost…. Cost… Cost…

  • no buying, installing, operating cost
  • eliminates the need for planning, purchasing, and provisioning expensive hardware
  • manages critical operating system updates and management tasks, and letting to focus on the user needs
  • Turns capital expenses into operating expense
  • a pay-as-you-go pricing model, which provides high availability and dynamic scaling to match the usage of needs
  • For actual cost of Azure – pls visit Pricing & Licensing site

Printing a Webpage using Javascript – Part 2

Comming Soon…….. 🙂

What, Why and How Garbage Collector?

You can find lots of useful information from the msdn and other webpages…

Here are some points for understanding Garbage Collector (GC)

We can say Garbage Collector is used to free the memory (to allocate for another object) used by an object when the object is not longer used.

Considering the process of the GC, we can say:
1. When we create any object using new, the runtime will allocate memory in the next available location in the heap for that object to live.

2. It will be used by our code for sometime…..

3. The object is considered as not reachable object when the object is not referred by any other object, or the object is not referring any object object, or all the reference are set to null for that object or when the execution come out of the scope

4. The Step 1 to 3 will be continuing for the object whatever creating at runtime. So the heap will be blocked by the objects.

5. The Garbage Collector (GC) decides to recollect the memory from the object when there is not enough memory for the new object creating (as per point 1).

6. The GC will collect the objects which are not longer reachable (as per point 3). Then it will move the reachable object in to the contiguous space and reclaim the memory used by other object. So the memory will be freed from the unused/unreachable object.

The collection process is fully automatic, but there are ways we can do programming to make the GC process more efficiently.

for more information, pls refer the msdn site.

Printing a Webpage using Javascript – Part 1

You can find the updated post Web page printing using javascript part 1

Even there are lots of ways to print the WebPages, the most fast and easy is using JavaScript window.print() function. This article trying to focus on this concept to achieve different format of printing.
 
1. Let us start with a simple example – printing the content of the page …….
The Requirement – We need to have an hyperlink to print the particular page.
<form id="form1" runat="server">
    <div id="Header">
        <h1>Viman Aerospace India Ltd</h1>
        <p style="text-align:right"><a href="#" style="text-align:right" onclick="window.print();">Print</a></p>
    </div>
    <div id="Content">
    <p>Viman Aerospace Limited started as a Software Service Company for Aerospace Industry in 2012. It provides software service for the avionics system used in Aircaft(Civil and Miltary). Due to good service provided by the company, it slowly developed as Avionics software development company in 2018. It produce software for avionics system like MIL-STD- 1553 etc. After long year of good service, its concentration moved to Aerospace industry. They joined  hands with small aerospace company POC India Limited to produce high ended simulation software. Then, they joined with SYS Group to produce civil Aircraft capable of carrying 200 passengers. Now in 2021 it became the First indian company to produce civil Aircraft indigeneouslly. it has a work force of dedicated 5000 workers working various centres in india. It head quarters lies in Thiruvallur district, Tamilnadu,India </p>
    </div>
    <div id="Footer">
        Copy Right© to Viman™ Company.
    </div>
</form>

2. Next the requirement is to popup a Print Preview page on click of the hyperlink where the user will have two buttons… Print – to print that preview, Cancel – the close the page and return.
<script language="javascript" type="text/javascript">
    function PrintContent()
    {
        printWindow= window.open ("", "mywindow", "location=0,status=0,scrollbars=1,width=600,height=600");
        printWindow.document.write("<div style='width:100%;text-align:left;'>");
        printWindow.document.write("<input type='button' id='btnPrint' value='Print' style='width:100px' onclick='window.print()' />");
        printWindow.document.write("<input type='button' id='btnCancel' value='Cancel' style='width:100px' onclick='window.close()' />");
        printWindow.document.write(document.getElementById('Content').innerHTML);
        printWindow.document.write(document.getElementById('Footer').innerHTML);
        printWindow.document.write("</div>");
        printWindow.document.close();
        printWindow.focus();
    }
</script>

<div id="Header">
    <h1>Viman Aerospace India Ltd</h1>
    <p style="text-align:right"><a href="#" style="text-align:right" onclick="PrintContent()">Print Preview</a></p>
</div>
<div id="Content">
    <p>Viman Aerospace Limited started as a Software Service Company for Aerospace Industry in 2012. It provides software service for the avionics system used in Aircaft(Civil and Miltary). Due to good service provided by the company, it slowly developed as Avionics software development company in 2018. It produce software for avionics system like MIL-STD- 1553 etc. After long year of good service, its concentration moved to Aerospace industry. They joined  hands with small aerospace company POC India Limited to produce high ended simulation software. Then, they joined with SYS Group to produce civil Aircraft capable of carrying 200 passengers. Now in 2021 it became the First indian company to produce civil Aircraft indigeneouslly. it has a work force of dedicated 5000 workers working various centres in india. It head quarters lies in Thiruvallur district, Tamilnadu,India </p>
</div>
<div id="Footer">
    Copy Right© to Viman™ Company.
</div>

3. The following examples are coded in ASP.NET 2.0 technology. So let us create a Masterpage which contains Header, Footer, and Left Menu. and another page contains the information about the company with print link.
The Master page (MasterPage.master)
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="Printing.MasterPage" %>
<!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" >
<head runat="server">
    <title>Printing Examples</title>
</head>
<body>
    <form id="form1" runat="server">
    <table style="width:100%;height:100%;border:1px;">
        <tr style="height:10%;">
           <td colspan="2" >
               <div id="Header">
                    <h1>Viman Aerospace India Ltd</h1>
                </div>
           </td>
        </tr>
        <tr style="height:80%;">
            <td style="vertical-align:top;">
                <asp:TreeView ID="TreeViewMenu" runat="server" DataSourceID="SiteMapDataSource1" >
                </asp:TreeView>
                <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="NavigateMenuSitemap" />
            </td>
            <td style="vertical-align:top;padding-left:10px;">
                <div id="Content">
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

                    </asp:ContentPlaceHolder>
                </div>
            </td>
        </tr>
        <tr style="height:10%;">
            <td colspan="2">
                <div id="Footer">
                    Copy Right© to Viman™ Company.
                </div>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
There is a Theam (Default) added into the project. Inside the Default.css file contains the following styles.
html, body, form {
    height: 100%;
    width: 100%;
}
body
{
    font-family: Calibri, Helvetica, sans-serif;
    font-size: 13px;
    color: #000000;
    margin: 0;
    padding: 0;
    text-align: left;
    background-color: White;
}
#Header
{
    text-align:center;
}
#ContentText
{
    text-align:left;
    font-size:12px;
    font-family:Calibri;
}
#Footer
{
    text-align:center;
    background-color:Fuchsia;
    vertical-align:middle;
    height:100%;
    width:100%;
}
The page (Sample3.aspx) contains the information about the company with the print hyperlink. On click of that hyperlink the whole page need to be printed (here no print preview).
<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Sample3.aspx.cs" Inherits="Printing.Sample3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <p style="text-align:right"><a href="#" style="text-align:right" onclick="window.print()">Print Preview</a></p>
    <div id="ContentText">
        <p>Viman Aerospace Limited started as a Software Service Company for Aerospace Industry in 2012. It provides software service for the avionics system used in Aircaft(Civil and Miltary). Due to good service provided by the company, it slowly developed as Avionics software development company in 2018. It produce software for avionics system like MIL-STD- 1553 etc. After long year of good service, its concentration moved to Aerospace industry. They joined  hands with small aerospace company POC India Limited to produce high ended simulation software. Then, they joined with SYS Group to produce civil Aircraft capable of carrying 200 passengers. Now in 2021 it became the First indian company to produce civil Aircraft indigeneouslly. it has a work force of dedicated 5000 workers working various centres in india. It head quarters lies in Thiruvallur district, Tamilnadu,India </p>
    </div>
</asp:Content>

3. Our next attempt is to print the page only the content and not the header, left menu, or footer. To achieve this we need to get the HTML script of the content page and write into the popup window. Let us have a look of this example
<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Sample3.aspx.cs" Inherits="Printing.Sample3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript" type="text/javascript">
        function PrintContent()
        {
            printWindow= window.open ("", "mywindow", "location=0,status=0,scrollbars=1,width=600,height=600");
            printWindow.document.write("<div style='width:100%;text-align:left;'>");
            printWindow.document.write("<input type='button' id='btnPrint' value='Print' style='width:100px' onclick='window.print()' />");
            printWindow.document.write("<input type='button' id='btnCancel' value='Cancel' style='width:100px' onclick='window.close()' />");
            printWindow.document.write(document.getElementById('Content').innerHTML);
            printWindow.document.write("</div>");
            printWindow.document.close();
            printWindow.focus();
        }
    </script>
    <p style="text-align:right"><a href="#" style="text-align:right" onclick="PrintContent()">Print Preview</a></p>
    <div id="ContentText">
        <p>Viman Aerospace Limited started as a Software Service Company for Aerospace Industry in 2012. It provides software service for the avionics system used in Aircaft(Civil and Miltary). Due to good service provided by the company, it slowly developed as Avionics software development company in 2018. It produce software for avionics system like MIL-STD- 1553 etc. After long year of good service, its concentration moved to Aerospace industry. They joined  hands with small aerospace company POC India Limited to produce high ended simulation software. Then, they joined with SYS Group to produce civil Aircraft capable of carrying 200 passengers. Now in 2021 it became the First indian company to produce civil Aircraft indigeneouslly. it has a work force of dedicated 5000 workers working various centres in india. It head quarters lies in Thiruvallur district, Tamilnadu,India </p>
    </div>
</asp:Content>
 
But this will popup the preview with the hyperlink, because the content page only contains the hyperlink. To avoid showing the hyperlink we can take the HTML script of ContentText div. So the code would change to
 
printWindow.document.write(document.getElementById(‘ContentText’).innerHTML);
 
Now the print preview does not have the same style (the colors, alignment defined in the style sheet Default.css). So to include the styles in the print preview add one line of code into the javacript pointing to the style sheet.
 
printWindow.document.write(“<link href=\”App_Themes/Default/Default.css\” type=\”text/css\” rel=\”stylesheet\” />”);
 
Again when the print prints in the priter, it contains the Print, Cancel buttons also. So how to hide this… the window contains two events onbeforeprint(), onafterprint() – that will be triggered before and after the browser taken it for printing.
 
The following example shows a complete example of the following
1. Shows Print Preview hyperlink

2. On click of that hyperlink – the system shall popup a screen with two buttons (Print and Cancel)

3. On click of Print button, the preview will be send to the printer without Print, Cancel buttons

4. The page shall show with the style (color, font styles etc.,)

5. The Print Preview shall have the proper title (Viman Aerospace India Ltd – Print Preview)

<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Sample3.aspx.cs" Inherits="Printing.Sample3" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript" type="text/javascript">
        function PrintContent()
        {
            var printWindow= window.open ("", "mywindow", "location=0,status=0,scrollbars=1,width=600,height=600");
            var strContent = "<html><head><title>Viman Aerospace India Ltd - Print Preview</title>";
            strContent = strContent + "<link href=\"App_Themes/Default/Default.css\" type=\"text/css\" rel=\"stylesheet\" />";
            strContent = strContent + "<script type=\"text/javascript\" language=\"javascript\">";
            strContent = strContent + "function window.onafterprint(){document.getElementById('buttons').style.display = '';}";
            strContent = strContent + "function window.onbeforeprint(){document.getElementById('buttons').style.display = 'none';}";
            strContent = strContent + "</scr" + "ipt>";
            strContent = strContent + "</head><body>";
            strContent = strContent + "<div id='buttons' style='width:100%;text-align:right;'>";
            strContent = strContent + "<input type='button' id='btnPrint' value='Print' style='width:100px' onclick='window.print()' />";
            strContent = strContent + "<input type='button' id='btnCancel' value='Cancel' style='width:100px' onclick='window.close()' />";
            strContent = strContent +  "</div>";
            strContent = strContent + "<div style='width:100%;'>";
            strContent = strContent + document.getElementById('ContentText').innerHTML;
            strContent = strContent + "</div>";
            strContent = strContent + "</body>";
            printWindow.document.write(strContent);
            printWindow.document.close();
            printWindow.focus();
        }
    </script>
    <p style="text-align:right"><a href="#" style="text-align:right" onclick="PrintContent()">Print Preview</a></p>
    <div id="ContentText">
        <p>Viman Aerospace Limited started as a Software Service Company for Aerospace Industry in 2012. It provides software service for the avionics system used in Aircaft(Civil and Miltary). Due to good service provided by the company, it slowly developed as Avionics software development company in 2018. It produce software for avionics system like MIL-STD- 1553 etc. After long year of good service, its concentration moved to Aerospace industry. They joined  hands with small aerospace company POC India Limited to produce high ended simulation software. Then, they joined with SYS Group to produce civil Aircraft capable of carrying 200 passengers. Now in 2021 it became the First indian company to produce civil Aircraft indigeneouslly. it has a work force of dedicated 5000 workers working various centres in india. It head quarters lies in Thiruvallur district, Tamilnadu,India </p>
    </div>
</asp:Content>