Monday, November 29, 2010

Asp.Net Framework Question Ans

1) what is .NET ?

.Net is a framework where we can develop different applications in a single environment using different type of languages


2)What is .NET Framework?


The .NET Framework has two main components: the common language runtime and

the .NET Framework class library.

You can think of the runtime as an agent that manages code at execution time,

providing core services such as memory management, thread management, and

remoting, while also enforcing strict type safety and other forms of code accuracy that

ensure security and robustness.

The class library, is a comprehensive, object-oriented collection of reusable types that

you can use to develop applications ranging from traditional command-line or

graphical user interface (GUI) applications to applications based on the latest

innovations provided by ASP.NET, such as Web Forms and XML Web services.


3) What is CLR?

The CLS is simply a specification that defines the rules to support language integration

in such a way that programs written in any language, yet can interoperate with one

another, taking full advantage of inheritance, polymorphism, exceptions, and other

features.

4) What are Generics in .Net framework 2.0?

Generics are related to the idea of Templates in C++. They permit classes, structs, interfaces, delegates, and methods to be parameterized by the types of data they store and manipulate. Without generics, general purpose methods or data structures (like Lists, Stacks, etc.) typically use the built-in Object type to store data of any type. While the use of the built-in Object type makes the implementation very flexible, it has drawbacks with regards to Performance and Type Safety.


5) What does the "EnableViewState" property do? Why would I want it on or off?

EnableViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code. This feature is not free however, since the state of a control is passed to and from the server in a hidden form field. You should be aware of when ViewState is helping you and when it is not.

6)What are the different modes for the sessionstates in the web.config file?

Off: Indicates that session state is not enabled.

Inproc: Indicates that session state is stored locally.

StateServer: Indicates that session state is stored on a remote server.

SQLServer: Indicates that session state is stored on the SQL Server.

7) Conditional Boating?
Bloating is an activity of performance improvement which is basically introduced in AJAX controls. The property UpdateMode is responsible for bloating for example the control updatepanel if you set UpdateMode Conditional then that clears your query.

8) What is the difference between Dataset.clone() and Dataset.copy()?
Using Dataset.clone() creates new instance of the same object.
Using Dataset.copy() copies content of data to another object wihtout creating new instance.

9) What is the difference between EVENTS and FUNCTIONS?
Event represents an action that is done to an object whereas Function represents an action that the object itself is doing.

10) what is the difference between application state and caching?
Application variable is the global variable specific to application but a
caching variable is specifc to page and time out.
Application variables exist as long as the application is alive. Whereas the cache has the Property of timeout which allows us to control the duration of the Objects so cached.
Another usefulness in caching is that we can define the way we cache our output since caching can be done in 3 ways -
a) Full Page - defined in page directrive
b) Partial Page - Eg - .ascx control
c) Data / Programatic caching. using the Properties of Cache object such as Cache.Insert .

NOTE:
Caching variable is specifc to page and time out
Application variable is the global variable specific to application

11) What is a Webcontrol?

Serves as the base class that defines the methods properties and events common to all controls in the System.Web.UI.WebControls namespace
A control is an object that can be drawn on to the Web Form to enable or enhance user interaction with the application. Examples of these controls include the TextBoxes Buttons Labels Radio Buttons etc. All these Web server controls are based on the System.Web.UI.Control class


12) Where do the Cookie State and Session State information be stored?

While executing the dynamic web page at the end of execution the value of session variables is calculated compressed and transmitted to the client via a Cookie. At this stage the state resides entirely and only on the client file system (or RAM).

Cookie Information will be stored in a txt file on client system under a
folder named Cookies. Search for it in your system you will find it.

Coming to Session State

As we know for every process some default space will be allocated by OS.

In case of InProc Session Info will be stored inside the process where our
application is running.

In case of StateServer Session Info will be stored using ASP.NET State Service.

In case of SQLServer Session info will be stored inside Database. Default DB
which will be created after running InstallSQLState Script is ASPState.

13) what is difference between key word &key filter?

The KeyFilter property is a new property that was added to control. Handling the KeyDown /KeyUp / KeyPress generates a callback on every key down which can be a great overhead if all you want is to handle a specific key down. That is way the new KeyFilter property was added. Basically it allows to define a filter which helps VWG generate callbacks only when you really need it. In the following sample code we have demonstrated the implementation of adding arrow behaviors to a set of text boxes which allows navigating between the fields.

Keyword is the reserved default words used by the language.


14) What is the difference between mechine.config and web.config?
Every asp.net application has web.cofig file. the settings given in this file is implied to that particular application only.But the settings given in machine.config file is implied to whole system.
Basically Machine.config file content the configuration setting for a particullar machine and Web.config file is used to store configure a particular web application. On any system there will be only one Machine.config file but Web.config file can number of time as per web application

15) What is the difference between Response.Redirect and Server.Transfer?

Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user's browser to another page or site. This performs a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

Response.Redriect means it can redirect the page which is located inside the application directory.server.transfer means it goes to another directory of the file.

Server.Transfer() send the request to server
Response.Redirect() sends the request to Browser
So If the Request is made for the location outside the Server it fails. so you need to use Respons.Redirect().

16) What is use of DataAdapater? and is it possible to add data from data reader directly to a dataset or a datatable?

DataAdapters purpose is to perform database queries and create dataTables containing the query results. Its also capable of writing changes made to the datataTables back to the database.

DataAdapter acts as a go-between providing a layer of abstraction between DataSet and the Physical Data sorce.


17) how many kinds of web services are there?

1) .Net web services

2) Java web services

3) brand X web services (built on SOAP)


18) what is name space for xml in asp.net

NameSpace : System.XML
Filde: System.Xml.dll


19) difference between remoting and web service in .net?explain with an example

in web service when the function which resides in the server is called by client side the message protocol used is soap and transfer protocol used is http.so all the message is first converted to xml format and serializes and use http transfer protocol for transfer to the server and again in server it gets deserialized and from the xml file it gets information about which fun ction is called by the client and what r the parameter.and agai return the value in xml format.As the message is passed in xml format it is platform independent

Remoting lets us enjoy the same power of web services when the platform is same.we can connect to the server directly over TCP and send binary data without having to do lots of conversion.


20) Explain the life cycle of an ASP .NET page.

Events in ASP.Net 1.1 & 2.0 :-



Application: BeginRequest
Application: PreAuthenticateRequest
Application: AuthenticateRequest
Application: PostAuthenticateRequest
Application: PreAuthorizeRequest
Application: AuthorizeRequest
Application: PostAuthorizeRequest
Application: PreResolveRequestCache
Application: ResolveRequestCache
Application: PostResolveRequestCache
Application: PreMapRequestHandler
Page: Construct
Application: PostMapRequestHandler
Application: PreAcquireRequestState
Application: AcquireRequestState
Application: PostAcquireRequestState
Application: PreRequestHandlerExecute
Page: AddParsedSubObject
Page: CreateControlCollection
Page: AddedControl
Page: AddParsedSubObject
Page: AddedControl
Page: ResolveAdapter
Page: DeterminePostBackMode
Page: PreInit
Control: ResolveAdapter
Control: Init
Control: TrackViewState
Page: Init
Page: TrackViewState
Page: InitComplete
Page: LoadPageStateFromPersistenceMedium
Control: LoadViewState
Page: EnsureChildControls
Page: CreateChildControls
Page: PreLoad
Page: Load
Control: DataBind
Control: Load
Page: EnsureChildControls
Page: LoadComplete
Page: EnsureChildControls
Page: PreRender
Control: EnsureChildControls
Control: PreRender
Page: PreRenderComplete
Page: SaveViewState
Control: SaveViewState
Page: SaveViewState
Control: SaveViewState
Page: SavePageStateToPersistenceMedium
Page: SaveStateComplete
Page: CreateHtmlTextWriter
Page: RenderControl
Page: Render
Page: RenderChildren
Control: RenderControl
Page: VerifyRenderingInServerForm
Page: CreateHtmlTextWriter
Control: Unload
Control: Dispose
Page: Unload
Page: Dispose
Application: PostRequestHandlerExecute
Application: PreReleaseRequestState
Application: ReleaseRequestState
Application: PostReleaseRequestState
Application: PreUpdateRequestCache
Application: UpdateRequestCache
Application: PostUpdateRequestCache
Application: EndRequest
Application: PreSendRequestHeaders
Application: PreSendRequestContent


------------

Page_Init -- Page Initialization

LoadViewState -- View State Loading

LoadPostData -- Postback data processing

Page_Load -- Page Loading

RaisePostDataChangedEvent -- PostBack Change Notification

RaisePostBackEvent -- PostBack Event Handling

Page_PreRender -- Page Pre Rendering Phase

SaveViewState -- View State Saving

Page_Render -- Page Rendering

Page_UnLoad -- Page Unloading


21) How to debug javascript or vbscript in .Net?
For debugging the client side script enable the debugging in IE.a. Open Microsoft Internet Explorer.b. On the Tools menu click Internet Options.c. On the Advanced tab locate the Browsing section clear the Disable script debugging check box and then click OK.d. Close Internet Explorer.

22) How to validate xmlschema in xml document?
One can validate the XML document againest a given schema using the .Net class under the package System.Xml.Schema; like using XMLSchemaValidator and XmlSchema.

23) What is the maximum number of cookies that can be allowed to a web site

- A maximum of 300 cookies can be stored on the user's system.
- No cookie can be larger than 4 kilobytes.
- No server or domain can place more than 20 cookies on a user's system. (One website can't hog all 300 cookies.)
- If you go beyond the maximum the browser will just discard old cookies to make room for the new ones.

24) What do you mean by authentication and authorization?
Authentication is the process of validating a user on the credentials (username and password) and authorization performs after authentication. After Authentication a user will be verified for performing the various tasks, It access is limited it is known as authorization.

25) What you thing about the WebPortal ?

Answer: Web portal is nothing but a page that allows a user to customize his/her homepage. We can use Widgets to create that portal we have only to drag and drop widgets on the page. The user can set his Widgets on any where on the page where he has to get them. Widgets are nothing but a page area that helps particular function to response. Widgets example are address books, contact lists, RSS feeds, clocks, calendars, play lists, stock tickers, weather reports, traffic reports, dictionaries, games and another such beautiful things that we can not imagine. We can also say Web Parts in Share Point Portal. These are one of Ajax-Powered.

26) How to start Outlook,NotePad file in AsP.NET with code ?
Answer: Here is the syntax to open outlook or notepad file in ASP.NET VB.NET Process.Start("Notepad.exe") Process.Start("msimn.exe"); C#.NET System.Diagnostics.Process.Start("msimn.exe"); System.Diagnostics.Process.Start("Notepad.exe");

27) What is the purpose of IIS ?
Answer: We can call IIS(Internet Information Services) a powerful Web server that helps us creating highly reliable, scalable and manageable infrastructure for Web application which runs on Windows Server 2003. IIS helps development center and increase Web site and application availability while lowering system administration costs. It also runs on Windows NT/2000 platforms and also for above versions. With IIS, Microsoft includes a set of programs for building and administering Web sites, a search engine, and support for writing Web-based applications that access database. IIS also called http server since it process the http request and gets http response.

28) What is the difference between Trace and Debug?
Trace and Debug - There are two main classes that deal with tracing - Debug and Trace. They both work in a similar way - the difference is that tracing from the Debug class only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only works in builds that have the TRACE symbol defined. Typically this means that you should use System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds, and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds.

29) What is @@connection?

The Query Designer supports the use of certain SQL Server constants, variables, and reserved column names in the Grid or SQL panes. Generally, you can enter these values by typing them in, but the Grid pane will not display them in drop-down lists. Examples of supported names include:
· IDENTITYCOL If you enter this name in the Grid or SQL pane, the SQL Server will recognize it as a reference to an auto-incrementing column.
· Predefined global values You can enter values such as @@CONNECTIONS and @@CURSOR_ROW into the Grid and SQL panes.
· Constants (niladic functions) You can enter constant values such as CURRENT_TIMESTAMP and CURRENT_USER in either pane.
· NULL If you enter NULL in the Grid or SQL panes, it is treated as a literal value, not a constant.

30) what is diff between varcher and nvarchar?

VARCHAR is an abbreviation for variable-length character string. It's a string of text characters that can be as large as the page size for the database table holding the column in question. The size for a table page is 8,196 bytes, and no one row in a table can be more than 8,060 characters. This in turn limits the maximum size of a VARCHAR to 8,000 bytes.
The "N" in NVARCHAR means uNicode. Essentially, NVARCHAR is nothing more than a VARCHAR that supports two-byte characters. The most common use for this sort of thing is to store character data that is a mixture of English and non-English symbols — in m UTF-8). That said, NVARCHAR strings have the same length restrictions as their VARCHAR cousins — 8,000 bytes. However, since NVARCHARs use two bytes for each character, that means a given NVARCHAR can only hold 4,000 characters (not bytes) maximum. So, the amount of storage needed for NVARCHAR entities is going to be twice whatever you'd allocate for a plain old VARCHAR.
Because of this, some people may not want to use NVARCHAR universally, and may want to fall back on VARCHAR — which takes up less space per row — whenever possible.
may case, English and Japanese.

31)What is the maximum size of the file that I can upload using file upload control?
Ans. 4MB

32) What class all aspx pages inherits?

Ans.
System.Web.UI.Page

33) What is NewID?
Yes, newid() is unique. newid() returns a globally unique identifier. newid() will be unique for each call of newid().
Thus, newid() can be used as the value of a primary key of a sql server table. Values returned by newid() can be inserted into a primary key column of type "uniqueidentifier". Here is an example of a "uniqueidentifier" primary key column, with newid() used as the default value:
CREATE TABLE [tblUsers] (
[UserId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[UserName] [varchar](256) NOT NULL,
PRIMARY KEY ([UserId])

34) What is the use of AutoWireup in asp.net?

AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.
In the case where AutoEventWireup attribute is set to false (by default) event handlers are automatically required for Page_Load or Page_Init. However when we set the value of the AutoEventWireup attribute to true the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.

35) how do you differentiate managed code and unmanaged code?

Managed code :Code that is executed by the CLR. Managed code provides information (i.e., metadata) to allow the CLR to locate methods encoded in assembly modules, store and retrieve security information, handle exceptions, and walk the program stack. Managed code can access both managed data and unmanaged data. Managed data—Memory that is allocated and released by the CLR using Garbage Collection. Managed data can only be accessed by managed code

Unmanaged Code:Unmanaged code is what you use to make before Visual Studio .NET 2002 was released. Visual Basic 6, Visual C++ , It is compiled directly to machine code that ran on the machine where you compiled it—and on other machines as long as they had the same chip, or nearly the same. It didn't get services such as security or memory management from an invisible runtime; it got them from the operating system. And importantly, it got them from the operating system explicitly, by asking for them, usually by calling an API provided in the Windows SDK. More recent unmanaged applications got operating system services through COM calls.



Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL) not to machine code that could run directly on your computer.Managed code runs in the Common Language Runtime.

Unmanaged code is what you use to make before Visual Studio .NET 2002 was released.It compiled directly to machine code that ran on the machine where you compiled it—and on other machines as long as they had the same chip or nearly the same.

-------

The code which is under control of CLR (Common Language Runtime) is called managed code.

The code which takes Operating System help while execution is called unmanaged code.

0 comments:

Post a Comment