devananddhage.files.wordpress.com€¦  · web viewsystem plus – tower 8 magarpatta city....

39
System Plus Tower 8 Magarpatta city SEQUENCE OF CATCH Synechron Phase 3 Hinjewadi HTTP HANDLER/MODULE DB EXCEPTION HANDLING SYNTAX OF TEMP TABLE CREATION OOPS IFACE CACHE AND SESSION FOR WHAT PURPOSE CACHING IS USED LINQ LAMBDA XPRESSION MVC –, VIEWBAG NEW IN .NET 4.0 VAR, DYNAMIC, URL ROUTINING etc. DATASET STATES GET/POST difference Mobien Shankarsheth Rd. Swargate (28 th Oct, 12) STATE MANAGEMENT ALTERNATIVE FOR VIEWSTATE SESSION TYPES WEB SERVICES SERIALIZATION VS 2012 FEATURES CLR/GARBASE COLLECTION SQL DB INDEX Why primary key not preferable in transaction table

Upload: others

Post on 29-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

System Plus – Tower 8 Magarpatta city

SEQUENCE OF CATCH

Synechron – Phase 3 Hinjewadi

HTTP HANDLER/MODULE

DB EXCEPTION HANDLING

SYNTAX OF TEMP TABLE CREATION

OOPS IFACE

CACHE AND SESSION

FOR WHAT PURPOSE CACHING IS USED

LINQ

LAMBDA XPRESSION

MVC –, VIEWBAG

NEW IN .NET 4.0 VAR, DYNAMIC, URL ROUTINING etc.

DATASET STATES

GET/POST difference

Mobien – Shankarsheth Rd. Swargate (28th Oct, 12)

STATE MANAGEMENT

ALTERNATIVE FOR VIEWSTATE

SESSION TYPES

WEB SERVICES

SERIALIZATION

VS 2012 FEATURES

CLR/GARBASE COLLECTION

SQL DB INDEX

Why primary key not preferable in transaction table

How many ways Stored Proc returns values

Page 2: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Inautix – Magarpatta City (3rd Nov, 12)

Cancelled

The Digital Group[T/DG] – Phase 1 Hinjewadi (24TH Nov, 12)

IIS ISOLATION LEVEL

ASP.NET PAGE LIFE CYCLE WITH USER CONTROL – details about the page events

COMBINE MULTIPLE DATASET USING LINQ, IS IT POSSIBLE?

ERROR HANDLING IN AJAX

ACT CALENDAR CONTROL – SHOW DEFAULT DATE

WEB SERVICE AND WCF

OOPS

ABOUT LAST PROJECT/ACHIEVEMENTS

SERVER.TRASFER AND RESPONSE.REDIRECT

USE OF USING BLOCK

BOXING/UNBOXING

LINQ – select into generic LIST

Dynamic Controls in Placeholder lossed after postback : http://forums.asp.net/t/1098870.aspx/1

Fiserv – Vimannagar

Page 3: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

ASP.Net, C#, Front endQ/A-

Source: http://stackoverflow.com/questions/365489/questions-every-good-net-developer-should-be-able-to-answer

Q: What is relation between GC, Finalize() and Dispose?

A: GC is garbage collection. It is the automatic memory management, that handles cleanup of objects allocated on the managed heap. The .NET GC employs a mark and sweep algorithm. When a garbage collection occurs it basically considers all object in the part of the heap to be cleaned as recoverable. Then it goes through a marking process where it scans for roots. I.e. it identifies objects that are still in use by the application. Having done that the remaining objects are eligible for cleanup. The heap may be compacted as part of the cleanup.

Dispose and finalizer methods both offer an option for cleaning resources, that are not handled by GC. E.g. this could be native handles and the like. They have nothing to do with reclaiming memory on the managed heap.

Dispose must be called explicitly on a type which implement IDisposable. It can be called either through the Dispose() method itself or via the using construct. The GC will not call Dispose automatically.

A finalizer or destructor (as the language specification calls it) on the other hand will automatically be called sometime after the object was eligible for cleanup. Finalize methods are executed sequentially on a dedicated thread.

Dispose() allows deterministic cleanup of resources while a finalizer can act as a safety net in case the user doesn't call Dispose().

If a type implements a finalizer, cleanup of instances is delayed as the finalizer must be called prior to cleanup. I.e. it will require an additional collect to reclaim the memory for instances of the type. If the type implements IDisposable as well, the Dispose method can be called and then the instance can remove itself from finalization. This will allow the object to be cleaned up as if it didn't have a finalizer.

Q: What’s the difference between an abstract class and interface? When would you want to use them?

Page 4: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

A: Summarizing: Use abstract classes and inheritance if you can make the statement "A is a B". Use interfaces if you can make the statement "A is capable of [doing] as", or also, abstract for what a class is, interface for what a class can do.

When we talk about abstract classes we are defining characteristics of an object type, specifying what an object is but in the case of an interface we define a capability and we bond to provide that capability, we are talking about establishing a contract about what the object can do.

Inheritance is a good choice when:

Your inheritance hierarchy represents an "is-a" relationship and not a "has-a" relationship.

You can reuse code from the base classes. You need to apply the same class and methods to different data types. The class hierarchy is reasonably shallow, and other developers are not likely to add

many more levels. You want to make global changes to derived classes by changing a base class.

There are several other reasons why you might want to use interfaces instead of class inheritance:

Interfaces are better suited to situations in which your applications require many possibly unrelated object types to provide certain functionality.

Interfaces are more flexible than base classes because you can define a single implementation that can implement multiple interfaces.

Interfaces are better in situations in which you do not need to inherit implementation from a base class.

Interfaces are useful in cases where you cannot use class inheritance. For example, structures cannot inherit from classes, but they can implement interfaces.

To allow a class to inherit multiple behaviors from multiple interfaces. To avoid name ambiguity between the methods of the different classes as was in the

use of multiple inheritances in C++.

Here are some recommendations to help you to decide whether to use an interface or an abstract class to provide polymorphism for your components.

If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.

If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are

Page 5: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.

If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.

If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.

Real time example: http://www.expertsblog.in/post/Real-World-Examples-Of-Abstract-Classes-And-Interfaces.aspx

Factory Method: http://forums.asp.net/t/1655294.aspx/1

http://en.csharp-online.net/Should_I_use_an_abstract_class_or_an_interface%3F

Theory: http://www.thecoldsun.com/en/content/01-2009/abstract-classes-and-interfaces

http://msdn.microsoft.com/en-us/library/27db6csx%28VS.80%29.aspx#Mtps_DropDownFilterText

http://msdn.microsoft.com/en-us/library/3b5b8ezk%28v=vs.80%29.aspx

Q: What is basic difference between SERVER.TRASFER and RESPONSE.REDIRECT?

A: SERVER.TRASFER changes the page being rendered. All happens over server.

With a call to RESPONSE.REDIRECT, the server basically sends an HTTP header back to the client browser with an HTTP status code stating that the object has moved along with the new location to find it.

Q: What's the difference between a left join and an inner join?

A:

Q: What's the difference between viewstate and sessionstate?

A:

Q: What's the difference between overriding and overloading a method? Explain how both are done.

A:

Page 6: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Q: What's the difference between protected and internal? What about "protected internal"?

A:

Q: How do short-circuited operators work?

A:

Q: Explain what the StringBuilder class is and why you'd want to use it?

A:

Q: What's the difference between a static method and a non-static method?

A:

Q: What does the "volatile" keyword in C# mean?

A:

Q: Explain what happens when you pass a "ref" or "out" parameter into a method. What's the difference between those two keywords?

A:

Q: What's a weakreference? When would you want to use one?

A:

Q: What's the difference between a DataTable and a DataReader?

A:

Q: What's the difference between a value-type and a reference type?

A:

Page 7: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Q: What does the "readonly" keyword in C# mean?

A:

Q: Why don’t we have multiple inheritance in .NET?

A: There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritances, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritances have.

Q: Write your own linked list class without using the built-in classes.

A:

Q: Write your own hashtable class without using the built-in classes.

A:

Q: Write a class that represents a binary tree. Write a method that traverses all nodes of the tree.

A:

Q: Write a method to perform a binary search on an array without using built-in methods.

A:

Q: Draw a database schema for a blog. Each user only has one blog, each blog has many categories, each category has many posts, and each post can belong to more than one category. Ask your applicant to write queries to pull specific information out.

A:

Page 8: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Q: What are the new features added into VS2010?

A:

IDE

Debugging Reverse Engineering Coding Generate sequence diagram DLR Managed extensibility F/W Support for parallel computing ADO.Net, WCF, WWF

ASP.Net

Static IDs for ASP.Net controls Chart control Web.config transformation

C#

Dynamic Types Optional parameters Named and Optional Arguments

Topics

1. MVCRef: http://stephenwalther.com/archive/2009/04/13/asp-net-mvc-tip-50-ndash-create-view-models.aspx

2. Serialization

What is it serialization?

When you create an object in a .Net framework application, you don't need to think about how the data is stored in memory. Because .Net framework takes care of that for you. However, if you want to store the contents of an object to a file, send an object to another process or transmit it across the network, you do have to think about how the object is represented because you will need to convert it to a different format. This conversion is called SERIALIZATION.

Page 9: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Uses of Serialization

The advantage of serialization is the ability to transmit data across the network in a cross-platform-compatible format, as well as saving it in a persistent or non-persistent storage medium in a non-proprietary format. Serialization is used by Remoting, Web Services SOAP for transmitting data between a server and a client.

Serialization allows the developer to save the state of an object and recreate it as needed, providing storage of objects as well as data exchange. Through serialization, a developer can perform actions like sending the object to a remote application by means of a Web Service, passing an object from one domain to another, passing an object through a firewall as an XML string, or maintaining security or user-specific information across applications.

Apply the SerializableAttribute attribute to a type to indicate that instances of this type can be serialized. Apply the SerializableAttribute attribute even if the class also implements the ISerializable interface to control the serialization process.

All the public and private fields in a type that are marked by the SerializableAttribute are serialized by default, unless the type implements the ISerializable interface to override the serialization process. The default serialization process excludes fields that are marked with the NonSerializedAttribute attribute. If a field of a serializable type contains a pointer, a handle, or some other data structure that is specific to a particular environment, and cannot be meaningfully reconstituted in a different environment, then you might want to apply the NonSerializedAttribute attribute to that field.

Interfaces define a contract and do not have any state of their own. Serialization is about saving and loading state into and out of an object model. Not much point to serializing something that holds no state.

To answer the practical question of forcing an implementation of an interface to be Serializable - this is why the ISerializable interface exists.

In .NET you can declare an interface that should implement other interfaces:

interface MustBeSerializable : ISerializable {}

Types of Serialization Binary – Faster, support complex object serialization and de-serialization, not provide platform

compatibility XML-

Page 10: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

SOAP- Portable Custom

De-serializationDe-serialization is the reverse; it is the process of reconstructing the same object later. The Remoting technology of .NET makes use of serialization to pass objects by value from one application domain to another.

3. State Management

Session - http://www.codeproject.com/Articles/32545/Exploring-Session-in-ASP-Net

4. Web Service

Q: Which protocol is used in web service?

A: To send and receive messages using SOAP over HTTP only.

While WCF uses any format (Default: SOAP) over any protocol (HTTP, TCP/IP, NamedPipes, MSMQ).

Q: How can we achieve function overloading in web service?

A: WSDL not supports the same function names and throws runtime error.

The procedure to solve this problem is very easy. Start each method with a Web Method attribute. Add Description property to add a description of web method and MessageName property to change web method name.

E.G.

namespace TestOverloadingWebService { [WebService(Namespace = "http://tempuri.org/", Description=" <b> Function overloading in Web Services </b>")]

public class OverloadingInWebService : System.Web.Services.WebService { [WebMethod(MessageName = "AddInt", Description = "Add two integer Value", EnableSession = true)] public int Add(int a, int b) { return (a + b); } [WebMethod(MessageName = "AddFloat", Description = "Add two Float Value", EnableSession = true)]

Page 11: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

public float Add(float a, float b) { return (a + b); } }

}

5. WCF

Ref: http://wcftutorial.net/Introduction-to-WCF.aspx

Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF. It is unified programming model provided in .Net Framework 3.0. WCF is a combined features of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.

Advantage

1. WCF is interoperable with other services when compared to .Net Remoting, where the client and service have to be .Net.

2. WCF services provide better reliability and security in compared to ASMX web services.3. In WCF, there is no need to make much change in code for implementing the security

model and changing the binding. Small changes in the configuration will make your requirements.

4. WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.

Disadvantage

Making right design for your requirement is little bit difficult.

Difference between WCF and Web service

Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service; following table provides detailed difference between them.

Features Web Service WCF

Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service

Programming [WebService] attribute has to be [ServiceContract] attribute has to be

Page 12: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

added to the class added to the class

Model [WebMethod] attribute represents the method exposed to client

[OperationContract] attribute represents the method exposed to client

OperationOne-way, Request- Response are the different operations supported in web service

One-Way, Request-Response, Duplex are different type of operations supported in WCF

XML System.Xml.serialization name space is used for serialization

System.Runtime.Serialization namespace is used for serialization

EncodingXML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom

XML 1.0, MTOM, Binary, Custom

Transports Can be accessed through HTTP, TCP, Custom

Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom

Protocols Security Security, Reliable messaging, Transactions

Q: How can we achieve function overloading in WCF?

A: E.G.

[ServiceContract]interface IMyCalculator{ [OperationContract(Name = "SumInt")] int Sum(int arg1,int arg2);

[OperationContract(Name = "SumDouble")] double Sum(double arg1,double arg2);}

6. HttpHandlerRecall that to configure a Web application to use an HTTP handler we need to map some

file extension (or a specific path) to the HTTP handler. We could make up our own extension, like .simple, but in doing so we'd have to configure IIS to map the .simple extension to the ASP.NET engine's ISAPI Extension (aspnet_isapi.dll). If you are hosting your site on a shared Web server, chances are the Web hosting company doesn't allow you to add custom mappings to the IIS metabase. Fortunately, when the .NET Framework is installed on a Web server the extension .ashx is automatically added and mapped to the ASP.NET engine's ISAPI Extension. This extension, then, can be used for custom HTTP handlers if you do not have access or permissions to modify the IIS metabase.Ref: http://www.codedigest.com/Articles/ASPNET/35_HttpHandler_in_ASPNet_PART_1.aspx

Page 13: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

HttpHandler is a program that is executed to complete the request processing when a client requests an ASP.Net resource like aspx page.

For example, when a user or client request for an ASPX page say http://localhost/WebApp/Default.aspx. The request is first received by the IIS i.e., inetinfo.exe. IIS can resolve the page if it is a static file like HTML, since it is ASPX page it forwards the request to ISAPI filters which is aspnet_isapi.dll in our case. It is the isapi filter that is used in handling ASP.Net Request. The isapi filter forwards the request to the worker process which is aspnet_wp.exe in our case. The worker process is the one who execute the request and give back the HTML output back to the client.

It is a .Net component that implements System.Web.IHttpHandler interface.HttpHandlers can be implemented in 2 ways,

Synchronous HttpHandler Asynchronos HttpHandler

A Synchronous HttpHandler should implement System.Web.IHttpHandler interface while an asynchronous HttpHandler should implement System.Web.IHttpAsyncHandler.

E.G.

public class clsMyHandler : IHttpHandler{

public void ProcessRequest(System.Web.HttpContext context){

context.Response.Write("The page request is " + context.Request.RawUrl.ToString());StreamWriter sw = new StreamWriter(@"C:\requestLog.txt",true);sw.WriteLine("Page requested at " + DateTime.Now.ToString() +

context.Request.RawUrl); sw.Close();}public bool IsReusable{

get{return true;}

}}And web.config

<system.web><httpHandlers><add verb="*" path="*.cust1,*.cust2" type="MyPipeLine.clsMyHandler, MyPipeLine"/></httpHandlers></system.web>

Page 14: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

7. HttpModule

HttpModule is an event pre-processor. So the first thing is to implement the IHttpModule and register the necessary events which this module should subscribe. For instance, we have registered in this sample for BeginRequest and EndRequest events. In those events, we have just written an entry on to the log file.

E.G.

public class cls MyModule : IHttpModule{

public clsMyModule(){}public void Init(HttpApplication objApplication){// Register event handler of the pipe lineobjApplication.BeginRequest += new EventHandler(this.context_BeginRequest);objApplication.EndRequest += new EventHandler(this.context_EndRequest);}public void Dispose(){}public void context_EndRequest(object sender, EventArgs e){StreamWriter sw = new StreamWriter(@"C:\requestLog.txt",true);sw.WriteLine("End Request called at " + DateTime.Now.ToString()); sw.Close();}public void context_BeginRequest(object sender, EventArgs e){StreamWriter sw = new StreamWriter(@"C:\requestLog.txt",true);sw.WriteLine("Begin request called at " + DateTime.Now.ToString()); sw.Close();

}}And web.config

<httpModules><add name="clsMyModule" type="MyPipeLine.clsMyModule, MyPipeLine"/></httpModules>

8. CachingCaching is a technique where we can store frequently used data, and web pages are

stored temporarily on the local hard disk for later retrieval. This technique improves the access time when multiple users access a web site simultaneously, or a single user accesses a web site multiple times. Caching for web applications can occur on the client (browser caching), on a server between the client and the web server, (proxy caching / reverse proxy caching), and on the web server itself (page caching or data caching).

ASP.Net provides support for Page, Page output, Partial page and Data caching.

Page 15: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

<%@ Page Language="C#" %><%@ OutputCache Duration='300' VaryByParam='none' %>

Attribute Values DescriptionDuration Number Defines how long the page will be cached (in seconds).

Location

'Any'

'Client'

'Downstream'

'Server'

'None'

It defines the page cache location.

VaryByCustom 'Browser' Vary the output cache either by browser name and version or by a custom string.

VaryByParam 'none' '*'This is a required attribute, which is required for a parameter for the page. * means for all the instances of page having different querysting value

9. ASP.Net Page life cycle

Ref: http://www.codeproject.com/Articles/73728/ASP-NET-Application-and-Page-Life-Cycle

http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic1

http://www.dotnetfunda.com/articles/article821-beginners-guide-how-iis-process-aspnet-request.aspx

(Tip: In above link they have given the kernel mode and user mode of IIS)

Introduction

In ASPX page life cycle there are different events which take place right from the time the user sends a request, until the time the request is rendered on the browser. So we will first try to understand the two broader steps of an ASP.NET request and then we will move into different events emitted from ‘HttpHandler’, ‘HttpModule’ and ASP.NET page object.

Overview: The Two Step Process

From 30,000 feet level, ASP.NET request processing is a 2 step process as shown below. User sends a request to the IIS:

Page 16: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

ASP.NET creates an environment which can process the request. In other words, it creates the application object, request, response and context objects to process the request.

Once the environment is created, the request is processed through a series of events which is processed by using modules, handlers and page objects. To keep it short, let's name this step as MHPM (Module, handler, page and Module event), we will come to details later.

In the coming sections, we will understand both these main steps in more detail.

Creation of ASP.NET Environment

Step 1: The user sends a request to IIS. IIS first checks which ISAPI extension can serve this request. Depending on file extension the request is processed. For instance, if the page is an ‘.ASPX page’, then it will be passed to ‘aspnet_isapi.dll’ for processing.

Step 2: If this is the first request to the website, then a class called as ‘ApplicationManager’ creates

Page 17: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

an application domain where the website can run. As we all know, the application domain creates isolation between two web applications hosted on the same IIS. So in case there is an issue in one app domain, it does not affect the other app domain.

Step 3: The newly created application domain creates hosting environment, i.e. the ‘HttpRuntime’ object. Once the hosting environment is created, the necessary core ASP.NET objects like ‘HttpContext’ , ‘HttpRequest’ and ‘HttpResponse’ objects are created.

Step 4: Once all the core ASP.NET objects are created, ‘HttpApplication’ object is created to serve the request. In case you have a ‘global.asax’ file in your system, then the object of the ‘global.asax’ file will be created. Please note global.asax file inherits from ‘HttpApplication’ class.Note: The first time an ASP.NET page is attached to an application, a new instance of ‘HttpApplication’ is created. Said and done to maximize performance, HttpApplication instances might be reused for multiple requests.

Step 5: The HttpApplication object is then assigned to the core ASP.NET objects to process the page.

Step 6: HttpApplication then starts processing the request by HTTP module events, handlers and

Page 18: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

page events. It fires the MHPM event for request processing.

The below image explains how the internal object model looks like for an ASP.NET request. At the top level is the ASP.NET runtime which creates an ‘Appdomain’ which in turn has ‘HttpRuntime’ with ‘request’, ‘response’ and ‘context’ objects.

Page 19: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Process Request using MHPM Events Fired

Once ‘HttpApplication’ is created, it starts processing requests. It goes through 3 different sections ‘HttpModule’ , ‘Page’ and ‘HttpHandler’. As it moves through these sections, it invokes different events which the developer can extend and add customize logic to the same.Before we move ahead, let's understand what are ‘HttpModule’ and ‘HttpHandlers’. They help us to inject custom logic before and after the ASP.NET page is processed. The main differences between both of them are:

If you want to inject logic based in file extensions like ‘.ASPX’, ‘.HTML’, then you use ‘HttpHandler’. In other words, ‘HttpHandler’ is an extension based processor.

Page 20: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

If you want to inject logic in the events of ASP.NET pipleline, then you use ‘HttpModule’. ASP.NET. In other words, ‘HttpModule’ is an event based processor.

Below is the logical flow of how the request is processed. There are 4 important steps MHPM as explained below:

Step 1(M: HttpModule): Client request processing starts. Before the ASP.NET engine

Page 21: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

goes and creates the ASP.NET HttpModule emits events which can be used to inject customized logic. There are 6 important events which you can utilize before your page object is created BeginRequest, AuthenticateRequest, AuthorizeRequest, ResolveRequestCache, AcquireRequestState and PreRequestHandlerExecute.

Step 2 (H: ‘HttpHandler’): Once the above 6 events are fired, ASP.NET engine will invoke ProcessRequest event if you have implemented HttpHandler in your project.

Step 3 (P: ASP.NET page): Once the HttpHandler logic executes, the ASP.NET page object is created. While the ASP.NET page object is created, many events are fired which can help us to write our custom logic inside those page events. There are 6 important events which provides us placeholder to write logic inside ASP.NET pages Init, Load, validate, event, render and unload. You can remember the word SILVER to remember the events S – Start (does not signify anything as such just forms the word) , I – (Init) , L (Load) , V (Validate), E (Event) and R (Render).

Step4 (M: HttpModule): Once the page object is executed and unloaded from memory, HttpModule provides post page execution events which can be used to inject custom post-processing logic. There are 4 important post-processing events PostRequestHandlerExecute, ReleaserequestState, UpdateRequestCache and EndRequest.The below figure shows the same in a pictorial format.

Page 22: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION
Page 23: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

In What Event Should We Do What?

The million dollar question is in which events should we do what? Below is the table which shows in which event what kind of logic or code can go.

Section Event Description

HttpModule BeginRequestThis event signals a new request; it is guaranteed to be raised on each request.

HttpModule AuthenticateRequestThis event signals that ASP.NET runtime is ready to authenticate the user. Any authentication code can be injected here.

HttpModule AuthorizeRequestThis event signals that ASP.NET runtime is ready to authorize the user. Any authorization code can be injected here.

HttpModule ResolveRequestCache

In ASP.NET, we normally use outputcache directive to do caching. In this event, ASP.NET runtime determines if the page can be served from the cache rather than loading the patch from scratch. Any caching specific activity can be injected here.

HttpModule AcquireRequestStateThis event signals that ASP.NET runtime is ready to acquire session variables. Any processing you would like to do on session variables.

HttpModule PreRequestHandlerExecute This event is raised just prior to handling control to the HttpHandler.

Page 24: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Section Event Description

Before you want the control to be handed over to the handler any pre-processing you would like to do.

HttpHandler ProcessRequestHttphandler logic is executed. In this section, we will write logic which needs to be executed as per page extensions.

Page Init

This event happens in the ASP.NET page and can be used for:

Creating controls dynamically, in case you have controls to be created on runtime.

Any setting initialization. Master pages and the settings.

In this section, we do not have access to viewstate, postedvalues and neither the controls are initialized.

Page LoadIn this section, the ASP.NET controls are fully loaded and you write UI manipulation logic or any other logic over here.

Page ValidateIf you have valuators on your page, you would like to check the same here.

RenderIt’s now time to send the output to the browser. If you would like to make some changes to the final HTML which is going out to the browser, you can enter your HTML logic here.

Page Unload Page object is unloaded from the memory.

HttpModule PostRequestHandlerExecute Any logic you would like to inject after the handlers are executed.

HttpModule ReleaserequestStateIf you would like to save update some state variables like session variables.

HttpModule UpdateRequestCache Before you end, if you want to update your cache.

HttpModule EndRequestThis is the last stage before your output is sent to the client browser.

Page 25: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

Zooming ASP.NET Page Events

In the above section, we have seen the overall flow of events for an ASP.NET page request. One of the most important sections is the ASP.NET page, we have not discussed the same in detail. So let’s take some luxury to describe the ASP.NET page events in more detail in this section.

Any ASP.NET page has 2 parts, one is the page which is displayed on the browser which has HTML tags, hidden values in form of viewstate and data on the HTML inputs. When the page is posted, these HTML tags are created in to ASP.NET controls with viewstate and form data tied up together on the server. Once you get these full server controls on the behind code, you can execute and write your own login on the same and render the page back to the browser.

Now between these HTML controls coming live on the server as ASP.NET controls, the ASP.NET page emits out lot of events which can be consumed to inject logic. Depending on what task / logic you want to perform, we need to put this logic appropriately in those events.Note: Most of the developers directly use the page_load method for everything, which is not a good thought. So it’s either populating the controls, setting view state, applying themes, etc., everything happens on the page load. So if we can put logic in proper events as per the nature of the logic, that would really make your code clean.

Page 26: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

# EventsControls Initialized

View state Available

Form dataAvailable

What Logic can be written here?

1 Init No No No

Note: You can access form data etc. by using ASP.NET request objects but not by Server controls.Creating controls dynamically, in case you have controls to be created on runtime. Any setting initialization.Master pages and them settings. In this section, we do not have access to viewstate , posted values and neither the controls are initialized.

2Load view state

Not guaranteed

YesNot guaranteed

You can access view state and any synch logic where you want viewstate to be pushed to behind code variables can be done here.

3 PostBackdataNot guaranteed

Yes YesYou can access form data. Any logic where you want the form data to be pushed to behind code variables can be done here.

4 Load Yes Yes Yes

This is the place where you will put any logic you want to operate on the controls. Like flourishing a combobox from the database, sorting data on a grid, etc. In this event, we get access to all controls, viewstate and their posted values.

5 Validate Yes Yes YesIf your page has validators or you want to execute validation for your page, this is the right place to the same.

6 Event Yes Yes Yes

If this is a post back by a button click or a dropdown change, then the relative events will be fired. Any kind of logic which is related to that event can be executed here.

7 Pre-render Yes Yes YesIf you want to make final changes to the UI objects like changing tree structure or property values, before these controls are saved in to view state.

8Save view state

Yes Yes YesOnce all changes to server controls are done, this event can be an opportunity to save control data in to view state.

9 Render Yes Yes Yes If you want to add some custom HTML to the output

Page 27: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

# EventsControls Initialized

View state Available

Form dataAvailable

What Logic can be written here?

this is the place you can.

10 Unload Yes Yes Yes Any kind of clean up you would like to do here.

Q: What is the sequence of loading master page and child page?

Page 28: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

A: 1. Page.OnPreInit (We can assign master page dynamically)

2. MasterPageControl.OnInit (for each control on the master page)

3. Control.OnInit (for each contol on the page)

4. MasterPage.OnInit

5. Page.OnInit

6. Page.OnInitComplete

7. Page.LoadPageStateFromPersistenceMedium

8. Page.LoadViewState

9. MasterPage.LoadViewState

10. Page.OnPreLoad

11. Page.OnLoad

12. MasterPage.OnLoad

13. MasterPageControl.OnLoad (for each control on the master page)

14. Control.OnLoad (for each control on the page)

15. OnXXX (control event)

16. MasterPage.OnBubbleEvent

17. Page.OnBubbleEvent

18. Page.OnLoadComplete

19. Page.OnPreRender

20. MasterPage.OnPreRender

21. MasterPageControl.OnPreRender (for each control on the master page)

22. Control.OnPreRender (for each control on the page)

23. Page.OnPreRenderComplete

Page 29: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

24. MasterPageControl.SaveControlState (for each control on the master page)

25. Control.SaveControlState (for each control on the page)

26. Page.SaveViewState

27. MasterPage.SaveViewState

28. Page.SavePageStateToPersistenceMedium

29. Page.OnSaveStateComplete

30. MasterPageControl.OnUnload (for each control on the master page)

31. Control.OnUnload (for each control on the page)

32. MasterPage.OnUnload

33. Page.OnUnload

SQLQ/A-

Q: How to boost the SQL server performance tuning?

A: Ref: http://sqlserverpedia.com/wiki/Performance_Tuning

Q: What are the DB Normalization steps?

A:

1NF: Eliminate Repeating Groups

Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.

2NF: Eliminate Redundant Data

If an attribute depends on only part of a multi-valued key, then remove it to a separate table.

Page 30: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

3NF: Eliminate Columns Not Dependent On Key

If attributes do not contribute to a description of the key, then remove them to a separate table. All attributes must be directly dependent on the primary key.

BCNF: Boyce-Codd Normal Form

If there are non-trivial dependencies between candidate key attributes, then separate them out into distinct tables.

4NF: Isolate Independent Multiple Relationships

No table may contain two or more 1:n or n:m relationships that are not directly related.

5NF: Isolate Semantically Related Multiple Relationships

There may be practical constrains on information that justify separating logically related many-to-many relationships.

ONF: Optimal Normal Form

A model limited to only simple (elemental) facts, as expressed in Object Role Model notation.

DKNF: Domain-Key Normal Form

A model free from all modification anomalies is said to be in DKNF.

Remember, these normalization guidelines are cumulative. For a database to be in 3NF, it must first fulfill all the criteria of a 2NF and 1NF database.

Topics-

10. MSSQL reporting SS(A/I/R)S

11. Stored Procedure

Syntax for sp is given below:

E.G.

CREATE PROCEDURE <Procedure_Name, sysname, ProcedureName> -- Add the parameters for the stored procedure here<@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>, <@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>

ASBEGIN

Page 31: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;

-- Insert statements for procedure hereSELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>

ENDGO

Returns values by two ways:

1. Output Parameter2. Return Code

12. CursorA cursor is a set of rows together with a pointer that identifies a current row.

In other word, Cursor is a database object used by applications to manipulate data in a set on a row-by-row basis; it is like recordset in the ASP and visual basic.

Declare cursor Open cursor Fetch row from the cursor Process fetched row Close cursor Deallocate cursor

Eg. Take a backup of databases

DECLARE @name VARCHAR(50) -- database name DECLARE @path VARCHAR(256) -- path for backup files DECLARE @fileName VARCHAR(256) -- filename for backup DECLARE @fileDate VARCHAR(20) -- used for file name

SET @path = 'D:\Project\db_bkup\'

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR FOR SELECT name from master.dbo.sysdatabasesWHERE name NOT IN ('master','model','msdb','tempdb')

OPEN db_cursor FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0 BEGIN SET @fileName = @path + @name + '_' + @fileDate + '.BAK' BACKUP DATABASE @name TO DISK = @fileName

Page 32: devananddhage.files.wordpress.com€¦  · Web viewSystem Plus – Tower 8 Magarpatta city. SEQUENCE OF CATCH. Synechron – Phase 3 Hinjewadi. HTTP HANDLER/MODULE. DB EXCEPTION

FETCH NEXT FROM db_cursor INTO @name END

CLOSE db_cursor DEALLOCATE db_cursor Type of Cursors

Forward-only Static Keyset Dynamic

Index

Trigger

References1. SQL

a. http://www.mssqltips.com/ b. http://blog.sqlauthority.com/sql-server-interview-questions-and-answers/ c.

2. ASP.Net / C#3. Front end