Friday, September 28, 2007

Assemblies Concept in .Net

Understanding Assemblies Concept in .Net

What is Assemblies in .Net?

  • Assembly is a logical collection of smallest unit in .Net Framework.
  • Example: .DLL File contains the application code, the .aspx file, .ascx user controls, .gif, .bmp, .ico file and other files like Resource file (.resx), etc.
  • In summary, Assemblies is a basic fundamental unit of application development and deployment in the .Net Framework
  • An assembly contains the MSIL code, which the common language runtime executes, and the type metadata.
  • An assembly also contains an assembly manifest that contains the assembly metadata. This metadata contains information about the assembly version, its security identity, the resources required by the assembly, and the scope of the assembly.
  • Assemblies are the smallest units to which the .NET Framework grants permissions. They provide security boundaries within the .NET Framework. You specify the permission required by your application while building assemblies. When the assembly is loaded into the runtime, the assembly sends a request to the runtime to grant the permission.
So now, lets Get Started with Assemblies .Net and understand concept of Assemblies in .Net by easy step by step explanation.

What is Assembly Manifest?
  • Assembly Manifest contains the metadata for the assembly.
  • Example, Assembly Manifest contains
    • Name and Version Information of Assembly.
    • Files (or Resource) that are made up the assembly.
    • Set of permissions required for the assembly to run properly.
    • And few other details depends on assembly.

How Assembly Manifest is useful?

When the Common Language Runtime (CLR) loads an assembly, it first reads the manifest to get the information regarding assembly.


Benefits of Assemblies?

  1. It is used in Versioning
  2. For Type Identification
  3. For Security
  4. For Deployment
  5. For Referencing.
  6. Improving Application Performance
  7. Better Code Management and Maintenance

What is "DLL Hell" Problem?
"DLL Hell" problem occurs due to version incompatibility of dll's.

DLL HELL is the problem that occures when an installation of a newer application might break or hinder other application as newer DLLs are copied into the system and the older application do not support or not compatible with them. .net overcomes this problem by supporting multiple versions of an assembly at any given time.this is called side-by-side component versioning.

More on "DLL Hell" Problem.
"DLL Hell" is a problem occurs when multiple applications attempt to share a common component like a dynamic link library (DLL) or a Component Object Model (COM) class. In the most typical case, one application will install a new version of the shared component that is not backward compatible with the version already on the machine. Although the application that has just been installed works well, existing applications that depended on a previous version of the shared component might no longer work.

How Assembly used in Avoiding "DLL Hell" Problem?
"DLL Hell" Problem is solved in .Net using Assembly.

Each assembly has a version number. All the types and resources in an assembly share the same version number to make it easy for applications to refer to the correct version of files and avoid problem of "DLL Hell". Thus assemblies allows the execution of multiple versions of the same assembly on the same machine. The side-by-side execution of assemblies overcomes the problem known as "DLL hell," which is one of the major problems associated with COM applications.


How Assembly can Improve Application Performance?
CLR is place where .Net Application codes gets compiled. Whenever you made an request to ASP.NET page, the page gets compiled first and then is transferred to the user. The compilation process is also completed in two steps.
  • 1. An IL (Intermediate Language) is generated and then this is handed over for JIT
  • 2. JIT (Just In Time) compilation which produces the machine code and our pages get displayed with their dynamic content.

The performance of our web application can be improved by creating pre-compiled libraries of IL which can then be handed over to JIT directly without having the inclusion of an extra process to make the conversion. This method is called componentization. Components are pre-compiled set of classes that have been developed in the form of DLL files and can then be included within our projects. This is also known as an assembly.


How Assembly can be used for Better Code Management and Maintenance
As we use Componentization(refer above description), if a code change require you need to change the component code compile it, so you do not require to change all the reference of code for minor change. For better understanding understand the example of component given below.


Types of Assemblies in .Net
  • Static and Dynamic Assemblies
  • Single-File and Multifile Assemblies
  • Private and Shared Assemblies
  • Satellite and Resource-only Assemblies

What is Static Assembly?
A static assembly is created when you compile the program using any of the .NET language compilers. A static assembly contains the types, interfaces, and various resources required by the assembly. A static assembly is stored on the hard disk in the form of a portable executable (.exe or .dll) file. In a simple term, when you compile through VS.Net it generates files which are physically stored on the disk, this files are called static assembly.


What is Dynamic Assembly?
Assemblies which are created and execute on the fly are called dynamic assembly. You can create dynamic assembly through System.Reflection.Emit namespace.

What is Single-File Assembly?
A single-file assembly consists of a single .exe or .dll file.
Example of Single File Assembly
In the example the Shape.dll generated is a Single File Assembly.


What is Multifile Assembly?
  • A multifile assembly is an assembly that can include multiple file, but it should contain atleast one .dll or .exe file.
  • Assembly manifest in multifile assembly can be attached to any assembly file or can be created seperately just the manifest.

What is Satellite Assembly?
Resource-only assemblies are assembly's that stores only resource and no code. example, Image. Resource-only assemblies that store the culture-specific information are known as satellite assemblies.

What is Private Assembly?
  • When you deploy an assembly which can be use by single application, than this assembly is called a private assembly.
  • Private assemblies can be used by only one application they are deployed with.
  • Private assemblies are deployed in the directory where the main application is installed.

What is Shared Assembly?
  • When you deploy an assembly which can be used by several application, than this assembly is called shared assembly.
  • Shared assemblies are stored in a special folder called Global Assembly Cache (GAC), which is accessible by all applications.
  • Shared assemblies must have a strong name. A strong name consists of an assembly name, a version number, a culture, a public key and an optional digital signature.
  • GAC is capable of maintaining multiple copies of an assembly with the same name but different versions.

How to assign strong name to assembly?
You can use strong name tool sn.exe tool to assign strong name to assembly. It provides
  • Name
  • Version
  • Integrity Protection.

How to provide High Security to assembly?
You can provide high security to assembly with the help of File Signing Tool, signcode.exe. It attach a publisher's digital signature to assembly. You can sign an assembly with both Strong Name Tool and the File Signing Tool, but when you use both make sure that you use Strong Name Tool before you use the File Signing Tool.


How to view content of GAC?
To view content of GAC open explorer and go to c:\Windows\assembly.


Native Assembly Vs JIT-Compiled Assembly
Assemblies store code in the MSIL (Microsoft Intermediate Language) Format. When a method is invoked for the first time, the CLR just-in-time (JIT) compiles that method into native machine code. The native code is stored in memory and directly used for subsequent calls to this method. In the JIT compilation mode, a method is slow when it is called for the first time because an additional step of compilation is invoked, but any subsequent calls to that method will run as fast as native code itself.
When you view the GAC, note that some assemblies have their type marked as native images, meaning that these assemblies were precompiled in native code before they were installed in the native image cache. The advangate of using a native image is that even the first call of any method in an assembly will be as fast as its subsequent calls. You too can create a native image for your assembly by using the Native Image Generator Tool, ngen.exe, which is installed as part of .net framework.


Releated Links

Design Patterns Concept in .Net

Understanding Design Patterns Concept in .Net Step by Step


Design Patterns in VB.NET is specifically designed to help Software Architects and Programmers to take advantage of Gang of Four (GoF) design patterns so that they can build object-oriented software which is flexible, reusable and easy to maintain. You will find that application of the concepts which you learn in this school will require you to spend more time upfront, when you first design and code object-oriented programs. However, over time, the maintenance of your VB.NET, C# and Java OO-programs will become much easier, less time consuming and much less error-prone. Programmers who maintain their program functionality--which is coded using GoF design patterns--will find themselves less and less in crisis mode and increasingly able to to extend the functionality of their object-oriented programs. This holds true for both Java and .NET developers.


Creational Patterns

Structural Patterns
And more Read @

Studying design patterns in VB.NET


Thursday, September 27, 2007

Free JavaScript Script

Lots of Free JavaScript Script that you can directly copy and paste in your web application.

Download Free Javascript @ http://www.javascriptkit.com/

Scripts Categories

JavaScript clocks, calendars, and timers

Special effects with background and document
Scrollers
Images and music effects
Combo Boxes
Image slideshows & galleries
Menu and redirection
Links
Windows, remotes, frames etc
Password protecting
Using cookies to store information about users.
User System (browser type, screen size, modified date, IP etc)
Math related
Form and form Validation
JavaScript Search Engines
Email and validation
Text effects
Random Stuff
Status Bar effects
Mouse Cursor effects
JavaScript Games
Messages
other
IE 4.x

Wednesday, September 26, 2007

Webcast on Aspiring Software Architect Program

Webcast on Aspiring Software Architect Program

Aspiring Software Architect Program (ASAP) Introduction and Architect’s Role in the Requirements phase
Introduction to ASAP for Application Architects followed by role of architects during the Requirements phase. This session is about how architects can influence better decisions that can pay dividends at the end of the project. In the session, we will discuss what are the project types, where to begin the capture, how it differs in different project types and execution models, how do we collate, prioritize and present the requirements. We end with a Case Study example to understand the approach.

Architecture and Design Fundamentals in the .NET World
This session talks about architecture from the .NET perspective. We will try to understand the roles of architects and designers in a software project. We will delve into patterns and practices, some of the enterprise solution patterns authored by Microsoft. We will discuss software factories and debate the viability of software factories. We will discuss tools and offerings from Microsoft and also some open source tools that enable Continuous Integration. Towards the end we will discuss the Architecture of the Case Study.

Abilities Design : Architecting for Performance
This session talks about how to architect and design applications for application performance with proven models. We will discuss various best practices used to architect, design and code applications that would help in providing consistent performance against industry benchmarks. We would also discuss various techniques to review, measure and tune performance.

Architecting the UI Layer
This session we would discuss how to architect consistent, scalable and high user performance user interface. We would also look at the end user productivity gains that organization can expect from a great UI, using the various UI design patterns, web client software factories and leveraging web 2.0/Ajax in creating a extensible environment.

Architecting End-to-End Security
This session focuses on the various security considerations that influence the development of the architecture of a .NET application. It starts with the business imperatives of considering security and the right amount of security to implement in the architecture. It also discusses security topics like authentication, authorization, auditing, single sign-on, external interface security, secure data transmission and storage as well as security architecture for SaaS scenario. It discusses the value of conducting threat modeling in application development and also the secure coding practices that must be implemented to mitigate the risks associated with the common attack vectors.

Designing Service and Business Layer
This session discusses the best practices around building business layer as well as service layer components. It also focuses on the importance of moving towards SOA and terminologies and ontology relevant to service orientation. This session also discusses the patterns and anti-patterns which are appropriate for business and service layer design/development. We will also talk about Microsoft’s Web Services Software Factories implementations which are useful to get started on SOA along with the case study.

Data Architecture
This session is about the guidelines for implementing a data tier in a multi-tier .NET based application. We discuss on what are the challenges faced during designing the data architecture and the considerations that an architect should take care of. We also discuss on different methods/patterns available for passing data across various layers and for e.g. how SaaS or SOA architectures influence these decisions.

Testing for Architects
This session is about how testing influences architecture, and how it helps architecture. We discuss the various types of testing - functional testing, non-functional testing (load tests, stress tests, etc.) and touch upon performance testing - what counters to look for, what some interpretations are, etc. We also look at testing in the current RIA / SOA world. We also look at Microsoft's offerings in the testing arena, and how to leverage these tools well.

Deployment and Management and Transitioning to an Architect
In this session we discuss on how Deployment Management directly impacts revenue and end customer satisfaction. We discuss the criticality to map system functional, non functional requirement to production physical environment in early stages and define deployment strategy. We will also talk about some of the key aspects to be considered while deployment like Management are Security Consideration, Rollback Process, Application Configuration Information, Error Logging Mechanism, System Alerts Management, Load Balancing and lot more.

More details

Web User Control in Asp.Net

All About User Controls in .Net

Getting started with Web User Control in Asp.net and lets explain it easy step by step.

What is Web User Control?
A Web User Control, is a Web Form. You can say it as a web form, which can be placed on multiple web form and can be reused.

Example of Web User Control in Asp.Net
You can use Web User Control to create to display User Status. i.e. based on whether user is logged-in or not display him appropriate message. If use is logged-in display "Welcome UserName" And if not than display message "Welcome Guest". You will understand it more practically latter in this article.

Extension of Web User Control in Asp.net
UI File: .ascx (Like Web form Compiled First time when WebPage is requested.)
Class File: .ascx.cs (Like Component Precompiled File, so it can improve performance)

Difference between Web Form and Web User Control
User Control are used within Web Form and do not contain the following HTML Tags.

  • <Head> Tag
  • <Body> Tag
  • <Form> Tag

Creating Web User Control in Asp.net
We are going to create a simple ImageViewer Control, which display thumnail view of image and on clicking "Original View" under it will redirect you to original view of Image. Practically it has is scrap, but I have used here so that example remain simple throughout the discussion.

Step1: Create Asp.net Website Project

Step2: Add User Control as shown in figure.



Select "Web User Control" from New Item Window and name it "ucImageViewer"




Step3: Now Add following code to file .ascx

Here it Adds a Image Server Control and Place a Button control below it. To organize properly it has displayed in table.

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="ucImageViewer.ascx.cs" Inherits="ucImageViewer" %>

<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<asp:Image ID="Image1" runat="server" />
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Original View"
OnClick="Button1_Click" />
</td>
</tr>
</table>


Step4: Now as we want to view "Original View" of Image, we need to write a code on button click control, so for that switch to code view i.e. open .ascx.cs file and add following code.

protected void Button1_Click(object sender, EventArgs e)
{
if (ImagePath == string.Empty)
return;
else
Response.Redirect(ImagePath);
}


Step5: Adding public property to Web User Control
Note, here you can access the Image Control property within User Control, but it won't be available when you place user control on web form, so to make desired ImageControl property accessible you need to define public property.

public string ImagePath
{
get
{
return m_ImagePath;
}
set
{
m_ImagePath = value;
}
}

public string ImageName
{
get
{
return m_ImageName;
}
set
{
m_ImageName = value;
}
}

public int ImageHeight
{
get
{
return m_ImageHeight;
}
set
{
m_ImageHeight = value;
}
}

public int ImageWidth
{
get
{
return m_ImageWidth;
}
set
{
m_ImageWidth = value;
}
}

So we are done forming Web User Control, now its turn to render Web User Control on Web Form.


Displaying Web User Control on Web Form in asp.net
To display web user control you can simply drag the user control on to web form as you are dragging web server control.

Lets understand manually how we can add the Web User Control on Web Form

Step1: Add Register directive
Like <%@ Page %> directive, you can create Register directive

<%@ Register Src="ucImageViewer.ascx" TagName="ImageViewer" TagPrefix="uc" %>

Understanding Attributes of Register directive

Src - It specifies source of web user control.
TagPrefix - It Specifies Prefix for user control, i.e. Namespace to which it belong.
TagName - It Specifies Alias to the user control. i.e. Id to Control.

Now, you need to add the control
<uc:ImageViewer ID="ImageViewer1" runat="server" />

Note: As we have form public property with Web User Control, we can access
ImagePath - To Specify path of Image.
ImageName - To display Image Name as alternate text.
ImageHeight
ImageWidth

Example:

protected void Page_Load(object sender, EventArgs e)
{
ImageViewer1.ImagePath = "Image/shriganesh1.jpg";
ImageViewer1.ImageName = "Shri Ganesh 1st Pic";
ImageViewer1.ImageHeight = 200;
ImageViewer1.ImageWidth = 200;
}

Displaying Output of Web User Control Rendering


After clicking button, it display Image Original View as shown in figure.




Now, lets understand how to load user control dynamically.

Dynamically Loading of User Control in asp.net

protected void Page_Load(object sender, EventArgs e)
{
Control c = Page.LoadControl("ucImageViewer.ascx");

((ucImageViewer)c).ImagePath = "Image/shriganesh1.jpg";
((ucImageViewer)c).ImageName = "Shri Ganesh Pic";
((ucImageViewer)c).ImageHeight = 150;
((ucImageViewer)c).ImageWidth = 150;

Panel1.Controls.Add(c);
}


Creating a Web User Control from Existing Web Form in Asp.net
Step1: Remove all <HTML>, <Body> and <Form> Tags.

Step2: Change the @Page directive to a @Control directive and ensures that no unsupported attributes remain.

Step3: Add a ClassName attribute to the @Control directive.

Step4: Rename the file to a name that reflects its purpose and then change the file extension from .aspx to .ascx.


Overview of Web Custom Control
Web Cutsom Controls provides more flexibility as compare to web user control. With Web Custom Control you can provide
  • Design-Time Support
  • Data Binding
  • Event Handling and more advance feature.

Different ways to create web custom control
There are 3 different ways of creating a web custom control
  1. Composite Control - By combining two or more controls.
  2. Derived Control - By Inheriting from a server control.
  3. From Scratch - By Inheriting from the generic System.Web.UI.Control class.

Composite Control - Web Custom Control
A composite control is a web custom control composed of two or more standard web server controls. Composite controls are useful when you have group of controls that must be repeated consistently on the UI of an application.

Derived Control - Web Custom Control
Derive Control are web custom control created by inheriting a web server control. Derived controls are useful when you want to enhance the existing server control.

Control from Scratch - Web Custom Control
You can create a control from scratch by deriving it from System.Web.UI.Control class and writing code to handle the rendering and other task. It is useful when you want most flexibility and control over the generated HTML.


Web User Control Vs Web Custom Control
Difference between Web User Control and Web Custom Control or Points to be consider while Choosing Web User Control or Web Custom Control
  • Web User Control can only be used within the same project, while Web Custom Control can be used across many projects.
  • Web User Control cannot be added to Visual Studio.Net Toolbox, while Web Custom Control can be added.
  • Web Custom Control are better choice when you want dynamic layout tasks in which constituent controls must be created at runtime.

Facts about Web User Control in asp.net
  • When you include a web user control in a web form, the user control participates in the event life cycle for the web form.
    • User control Load and PreRender events are fired only after the web form's load and PreRender events are fired respectively.
  • Web User controls are not precompiled into assemblies like the components and custome controls, they can only be used in web applications that have a physical copy of the user control. Thus, every application that wants to use a user control should have its own copy of that user control.
  • Web User Control cannot be added into Visual Studio.Net Toolbox
  • Web User Control do not expose their properties through the properties window
  • Web User Controls in asp.net are Language neutral, that is user control written in C# can be used on a web form that is written in VB.Net.

Releated Link
Component Creation in .Net

Tips, Tricks, Articles and Information on .Net by Scott Guthrie

Tips, Tricks, Articles and Information on .Net by Scott Guthrie

A list of Popular Articles and Tips and Tricks for

  • Visual Studio.Net 2005
  • Asp.Net UI Development Articles
  • AJAX Development Articles
  • Database Related article
  • Security Tips and Tricks in Asp.net
  • Deployment Articles
  • Articles on Enhancing Performance of Web Application
  • .Net 3.5 Vs Visual Studio 2008
  • LINQ Articles and Explanation
  • Silverlight Articles
Click here

Tuesday, September 25, 2007

Creating Component in .Net

Creating Component in .Net

What is Component?
It is a set pre-compiled class, which is reusable. For now, just stick to it at the end of article you will practically understand how it is reusable piece of code.

Advantages of Component

  • Improving Application Performance
  • Better Code Management and Maintenance

How Component can Improve Application Performance?
CLR is place where .Net Application codes gets compiled. Whenever you made an request to ASP.NET page, the page gets compiled first and then is transferred to the user. The compilation process is also completed in two steps.
  • 1. An IL (Intermediate Language) is generated and then this is handed over for JIT
  • 2. JIT (Just In Time) compilation which produces the machine code and our pages get displayed with their dynamic content.

The performance of our web application can be improved by creating pre-compiled libraries of IL which can then be handed over to JIT directly without having the inclusion of an extra process to make the conversion. This method is called componentization. Components are pre-compiled set of classes that have been developed in the form of DLL files and can then be included within our projects. This is also known as an assembly.


How Component can be used for Better Code Management and Maintenance
As we use Componentization(refer above description), if a code change require you need to change the component code compile it, so you do not require to change all the reference of code for minor change. For better understanding understand the example of component given below.


Example of Creating Component in .Net

Creating a simple demo of famous Class Shape Example, wherein simple functionality is added.

Step1:
Create a Asp.net web application

Step2: Right click the solution explorer and add New Project "class library project"
For example, Delete the .CS File and Add Component using Project > Add New Component and Name it as csShape.cs

Note: By creating component you are actually creating assembly file and it has all the benefits that assembly has. You can edit all the assembly details by right clicking "Class Library Project" and Selecting Properties from popup window.

Step3: Created a Four Class as shown in Class Diagram



For better understanding download the Shape.CS File

Step4: Compile the Class Library Project

Step5: Add Reference to Project




Step6: Test the component.

Add namespace
using Shape;

protected void Page_Load(object sender, EventArgs e)
{
csShape objShape = new csShape();
Response.Write("
" + "I am " + objShape.ShapeName
+ " Object and my color is " + objShape.Color);

csCircle objCircle = new csCircle();
objCircle.Color = "Blue";
Response.Write("
" + "I am " + objCircle.ShapeName
+ " Object and my color is " + objCircle.Color);

csSquare objSquare = new csSquare();
objSquare.Color = "Green";
Response.Write("
" + "I am " + objSquare.ShapeName
+ " Object and my color is " + objSquare.Color);

csRectangle objRectangle = new csRectangle();
objRectangle.Color = "Orange";
Response.Write("
" + "I am " + objRectangle.ShapeName
+ " Object and my color is " + objRectangle.Color);
}


Output of Application



So now if you want to change the functionality of Shape class you can do it independently you just need to rebuild the class library application and all changes are reference without any extra effort.

Sunday, September 23, 2007

Tool for checking Patterns and Practise in Asp.net Web Application

It is very hard to implement best practise always while coding, so too make your task easy a Tool is available, which checks for Patterns and Practise Implementation in your asp.net application and will guide you wherever you are not following the rule.

Screenshot of Pattern and Practise Checker Tool




patterns & practices Practices Checker is a tool that helps you verify your applications against the patterns & practices performance recommendations for ASP.NET applications.


Advantage of using Patterns and Practice Checker Tool

  • User Practices Checker to help you perform a manual code inspection by analyzing your application for potential coding and configuration settings that do not adhere to the patterns & practices ASP.NET Performance Checklist.
  • Extend Practices Checker by allowing additional checklists to be created and checked.
  • Developers can utilize built in search routines to search intermediate language, static text files and .configuration files for specific code patterns or settings.

Check out a video on it here.

Download it here.

Saturday, September 22, 2007

All About Web Service in .Net

This article will explain you everything about Web Services in .Net, so lets get started with Web Service

What is Web Service?

  • Web Service is an application that is designed to interact directly with other applications over the internet. In simple sense, Web Services are means for interacting with objects over the Internet.
  • Web Service is
    • Language Independent
    • Protocol Independent
    • Platform Independent
    • It assumes a stateless service architecture.
  • We will discuss more on web service as the article proceed. Before that lets understand bit on how web service comes into picture.

History of Web Service or How Web Service comes into existence?
  • As i have mention before that Web Service is nothing but means for Interacting with objects over the Internet.
  • 1. Initially Object - Oriented Language comes which allow us to interact with two object within same application.
  • 2. Than comes Component Object Model (COM) which allows to interact two objects on the same computer, but in different applications.
  • 3. Than comes Distributed Component Object Model (DCOM) which allows to interact two objects on different computers, but within same local network.
  • 4. And finally the web services, which allows two object to interact internet. That is it allows to interact between two object on different computers and even not within same local network.
Example of Web Service
  • Weather Reporting: You can use Weather Reporting web service to display weather information in your personal website.
  • Stock Quote: You can display latest update of Share market with Stock Quote on your web site.
  • News Headline: You can display latest news update by using News Headline Web Service in your website.
  • In summary you can any use any web service which is available to use. You can make your own web service and let others use it. Example you can make Free SMS Sending Service with footer with your companies advertisement, so whosoever use this service indirectly advertise your company... You can apply your ideas in N no. of ways to take advantage of it.

Web Service Communication
Web Services communicate by using standard web protocols and data formats, such as
  • HTTP
  • XML
  • SOAP
Advantages of Web Service Communication
Web Service messages are formatted as XML, a standard way for communication between two incompatible system. And this message is sent via HTTP, so that they can reach to any machine on the internet without being blocked by firewall.

Terms which are frequently used with web services
  • What is SOAP?
    • SOAP are remote function calls that invokes method and execute them on Remote machine and translate the object communication into XML format. In short, SOAP are way by which method calls are translate into XML format and sent via HTTP.
  • What is WSDL?
    • WSDL stands for Web Service Description Language, a standard by which a web service can tell clients what messages it accepts and which results it will return.
    • WSDL contains every details regarding using web service
      • Method and Properties provided by web service
      • URLs from which those method can be accessed.
      • Data Types used.
      • Communication Protocol used.
  • What is UDDI?
    • UDDI allows you to find web services by connecting to a directory.
  • What is Discovery or .Disco Files?
    • Discovery files are used to group common services together on a web server.
    • Discovery files .Disco and .VsDisco are XML based files that contains link in the form of URLs to resources that provides discovery information for a web service.
    • .Disco File (static)
      • .Disco File contains
        • URL for the WSDL
        • URL for the documentation
        • URL to which SOAP messages should be sent.
      • A static discovery file is an XML document that contains links to other resources that describe web services.
    • .VsDisco File (dynamic)
      • A dynamic discovery files are dynamic discovery document that are automatically generated by VS.Net during the development phase of a web service.
  • What is difference between Disco and UDDI?
    • Disco is Microsoft's Standard format for discovery documents which contains information about Web Services, while UDDI is a multi-vendor standard for discovery documents which contains information about Web Services.
  • What is Web Service Discovery Tool (disco.exe) ?
    • The Web Services Discovery Tool (disco.exe) can retrieve discovery information from a server that exposes a web service.
  • What is Proxy Class?
    • A proxy class is code that looks exactly like the class it meant to represent; however the proxy class doesn't contain any of the application logic. Instead, the proxy class contains marshalling and transport logic.
    • A proxy class object allows a client to access a web service as if it were a local COM object.
    • The Proxy must be on the computer that has the web application.
  • What is Web Service Description Language Tool (wsdl.exe)?
    • This tool can take a WSDL file and generate a corresponding proxy class that you can use to invoke the web service.
    • Alternate of generating Proxy class through WSDL.exe is you can use web reference. Web Reference automatically generate a proxy classes for a web service by setting a web reference to point to the web service.
    • Advantage of using Web Reference as compare to using WSDL.exe Tool is you can update changes done in web service class easily by updating web reference, which is more tedious task with WSDL.exe tool.
  • Testing a Web Service?
    • You can test web service without building an entire client application.
      • With Asp.net you can simply run the application and test the method by entering valid input paramters.
      • You can also use .Net Web Service Studio Tool comes from Microsoft.

Example of Creating Web Service in .Net

This Web Service will retrieve CustomerList Country Wise and return as dataset to client application for display.

Step1: Create a Web Service Application by File > New > Web Site > Asp.net Web Services
Named the web service, for example here i have choosen name "WSGetCustomerCountryWise"

Step2: Rename the default Service.asmx file to proper name, you also need to switch design view and change the class name with the same name you use to rename the service.asmx.
For example, "WSGetCustomerCountryWise.asmx" and switch to design view and change the class="Service" to class="WSGetCustomerCountryWise"

Step3: Rename the Service.CS File to proper name, you need to change the class name and constructor name too.
For example, "WSGetCustomerCountryWise.CS" and switch to code view and change the class and constructor name to "WSGetCustomerCountryWise"

After three steps your solution explorer looks as shown in figure




Step4: Create a Logic for Web Service
  • Create a Method "GetCustomerCountryWise"
  • Note: You need to specify [WebMethod] before method definition, if you want it to be accessible public, otherwise the method would not be accessible remotely.
  • Specify proper argument and return type for method in web service.
  • It is also good practise to specify the use "Description" attribute to tell what method is meant for.
For example, here i need to access data of northwind customers and want to return customer list country wise, so add namespace for

using System.Data;
using System.Data.SqlClient;
using System.Configuration;

[WebMethod(Description="It will generate Customer List, Country Wise")] public System.Xml.XmlElement GetCustomerCountryWise(string sCountry)
{
string sConn = ConfigurationManager.ConnectionStrings["connStr"].ToString();

string sSQL = "select CustomerId, CompanyName, ContactTitle, City " +
" from Customers where country = '" + sCountry + "'";

SqlConnection connCustomer = new SqlConnection(sConn);

DataSet dsCustomer = new DataSet();

SqlDataAdapter daCustomer = new SqlDataAdapter(sSQL, sConn);

daCustomer.Fill(dsCustomer,"Customers");

//Known bug while return "DataSet" is "Data source is an invalid type.
It must be either an IListSource, IEnumerable, or IDataSource."
//For more details on Error: http://support.microsoft.com/kb/317340

//So to access data we need to make use of XmlElement.

// Return the DataSet as an XmlElement.
System.Xml.XmlDataDocument xdd = new System.Xml.XmlDataDocument(dsCustomer);
System.Xml.XmlElement docElem = xdd.DocumentElement;
return docElem;
}


Step5: Build Web Service and Run the Web Service for testing by pressing F5 function key.






By pressing "Invoke" button will generate XML File.

So you are done creating web service application.

Example of Testing Web Service in .Net

This Web Service will display the information which had been retrieved from Remote computer by accessing public method "GetCustomerCountryWise".

Step1: Create a Test Web Site by File > New > Web Site > Asp.net Web Site
Named the web site, for example here i have choosen name "TestGetCustomerCountryWise"

Step2: Displaying data in gridview, so drag the gridview on to the form.

Step3: Right Click Solution Explorer and Choose "Add Web Reference"



Step4: Choose the option Web Service on the local machine or you can enter the .WSDL File address directly in URL space and press Go button.




Step5: Press "Add Reference button"


Step6: Writing Code for Displaying data in GridView
Here note: I have Pass "USA" as parameter in Country Field.

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//Create object of WSGetCustomerCountryWise Object
localhost.WSGetCustomerCountryWise objGetCustomerCountryWise
= new localhost.WSGetCustomerCountryWise();

DataSet dsCustomer = new DataSet();

// Get the data from Webservice.
XmlElement elem = objGetCustomerCountryWise.GetCustomerCountryWise("USA");

// Load the XML to the Typed DataSet that you want.
XmlNodeReader nodeReader = new XmlNodeReader(elem);
dsCustomer.ReadXml(nodeReader, XmlReadMode.Auto);

GridView1.DataSource = dsCustomer;

GridView1.DataBind();
}
}


Step7: Output as data displayed in GridView.




Few Facts about Web Service in .Net
  • Each Response from web service is a new object, with a new state.
  • Web Service are asynchronous because the request object from the client application and the response object from the web service are unique SOAP envelopes that do not require shared connection.
  • This allow client application and the web service to continue processing while the interaction is ongoing.
  • Instead of a user interface, it provides a standard defined interface called a contract.

Tuesday, September 18, 2007

Applying CSS to Asp.net Application

Understanding CSS

  • CSS stands for Cascading Style Sheet
  • CSS is used to apply common look and feel for your web application

Advantages of using CSS
  • It gives uniform look and feel to web application
  • Ease of maintenance

Applying CSS to asp.net web application
  • Applying CSS is easy
  • Create a .CSS File in notepad or you can use CSS Editor available with VS.Net
Let say i have create .CSS File and placed it in folder "CSS"

Create Sample .CSS File named "MyCSS.CSS" you can choose suitable name for .CSS File

Step1: Adding .CSS File to Web application



Now copy and paste the .CSS Content, example

To apply to following style to all Paragraph Tag.
p
{
color:Red;
font-size:x-large;
font-family:Verdana;
background-color:Gray;
}

To apply to following style to all Heading1 Tag.
h1
{
color:Blue;
background-color:Yellow;
font-family:Comic Sans MS;
}

Let say, I want to apply a specific style to Paragraph Tag to some Page3 in my Web Application, you can do this using "class" attribute of Paragraph Tag, here you need to apply <p class="pForMyPage3">.
.pForMyPage3
{
color:Gray;
font-size:x-large;
font-family:Verdana;
background-color:Red;
}

Similarly i have used same for button control.
.ButtonControl
{
background-color:Red;
color:Yellow;
}



Step2: Adding content to .CSS File




Step 3: Adding .CSS File Link into .aspx Page

See figure for knowing how to apply CSS to control and adding link tag.



Problem with using .CSS File in Asp.net Web Application
  • You cannot apply CSS to some asp.net server controls.

To Overcome .CSS File problem in Asp.net 2.0 Web Application
  • You can make use of Themes.

Monday, September 17, 2007

Best Practise for Improving .NET Application Performance and Scalability

Best Practise for Improving .NET Application Performance and Scalability

This guide provides end-to-end guidance for managing performance and scalability throughout your application life cycle to reduce risk and lower total cost of ownership. It provides a framework that organizes performance into a handful of prioritized categories where your choices heavily impact performance and scalability success. The logical units of the framework help integrate performance throughout your application life cycle. Information is segmented by roles, including architects, developers, testers, and administrators, to make it more relevant and actionable. This guide provides processes and actionable steps for modeling performance, measuring, testing, and tuning your applications. Expert guidance is also provided for improving the performance of managed code, ASP.NET, Enterprise Services, Web services, remoting, ADO.NET, XML, and SQL Server.

Part I, Introduction to Engineering for Performance

This part shows you how to apply performance considerations throughout your application life cycle and introduces fundamental performance and scalability concepts and terminology. Part I includes one chapter:

Part II, Designing for Performance

Performance modeling helps you assess your design choices before committing to a solution. By considering from the start your performance objectives, workload, and metrics for your scenarios, you reduce risk. Use the design guidelines chapter to learn practices, principles, patterns, and anti-patterns that will help you to make informed choices. Part II includes three chapters:

Part III, Application Performance and Scalability

This part provides a series of chapters that provide deep platform knowledge across the .NET Framework technologies. Use these chapters to learn about the key performance and scalability considerations for the various .NET technologies, and to improve the efficiency of your code in these areas. Part III includes nine chapters:

Part IV, Database Server Performance and Scalability

This part shows how to improve SQL Server performance. This part includes one chapter:

Part V, Measuring, Testing, and Tuning

This part shows which metrics monitor and analyze for specific performance aspects. It also explains how to load, stress, and capacity test your applications and how you can tune performance with appropriate application, platform, and system configuration. This part includes three chapters:

Checklists

This section contains printable, task-based checklists, which are quick reference sheets to help you put the information and details that you learned in the individual chapters into action. This section includes the following checklists:

How To Articles

This section contains How To articles that provide step-by-step procedures for key tasks. This section includes the following How To articles:

Sunday, September 16, 2007

Essential Resource for Web Developers

A nice article on Essential Resource for Web Developers

It contains 100+ Good links for Web Developers.

Read More...

Ajax Quality Resource and Tutorials

Ajax Quality Resource and Tutorials

A good link which contains 50+ Quality Resource and Tutorials for AJAX.

Read more

20 Tips to Improve ASP.net Application Performance

20 Tips to Improve ASP.net Application Performance

  • Disable Session State
  • Output Buffering
  • Avoid Server-Side Validation
  • Repeater Control Good, DataList, DataGrid, and DataView controls Bad
  • Take advantage of HttpResponse.IsClientConnected before performing a large operation
  • Use HTTPServerUtility.Transfer instead of Response.Redirect
  • Always check Page.IsValid when using Validator Controls
  • Deploy with Release Build
  • Turn off Tracing
  • Page.IsPostBack is your friend
  • Avoid Exceptions
  • Caching is Possibly the number one tip!
  • Create Per-Request Cache
  • Use of StringBuilder for String Manipulation
  • Turn Off ViewState
  • Use Paging
  • Use the AppOffline.htm when updating binaries
  • Use ControlState and not ViewState for Controls
  • Use the Finally Method
  • Option Strict and Option Explicit
Read Article in detail

Parallel Performance for .Net Application

Parallel Performance for .Net Application

Optimize Managed Code For Multi-Core Machines

Tuesday, September 04, 2007

Performance Tunning articles on SQL Server

Performance Tunning articles on SQL Server

Tips and Tricks for UpdatePannel in AJAX

Tips and Tricks for UpdatePannel in AJAX

Article on AJAX Architecture

A good link for understanding AJAX Architecture

Article on High Performance Asp.net Web Application

A good article on High Performance Asp.net Web Application, it contains some of the good points which are are uncommon from common checklist for High Performance asp.net web application.

10 Tips for Writing High-Performance Web Applications

Performance on the Data Tier
Tip 1—Return Multiple Resultsets
Tip 2—Paged Data Access
Tip 3—Connection Pooling
Tip 4—ASP.NET Cache API
Tip 5—Per-Request Caching
Tip 6—Background Processing
Tip 7—Page Output Caching and Proxy Servers
Tip 8—Run IIS 6.0 (If Only for Kernel Caching)
Tip 9—Use Gzip Compression
Tip 10—Server Control View State
Conclusion

Paypal Integration in Asp.net Shopping Cart Application

Paypal Integration in Asp.net Shopping Cart Application Example

This article shows how payments processing can be organized to support reliability and security. The article is also aimed at providing you with an example of the development of a simple online shop, in order to demonstrate interaction with the PayPal system. You can use the code in your applications to organize interaction with the PayPal system and to process payments.

Click here

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape