FAQ on Microsoft DotNet

How many languages .NET is supporting now?
Ans : When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNet Languages. Net says 44 languages are supported..

How is .NET able to support multiple languages?
Ans : A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language..

How ASP .NET different from ASP?
Ans : Scripting is separated from the HTML, Code is compiled as a DLL, and these DLLs can be executed on the server.

What is smart navigation?
Ans : The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

What is view state?
Ans: The web is stateless. But in ASP.NET, the state of a page is maintained in the page itself automatically. How? The values are encrypted and saved in hidden controls. This is done automatically by the ASP.NET. This can be switched off / on for a single control.

How do you validate the controls in an ASP .NET page?
Ans : Using special validation controls that are meant for this. We have Range Validator, Email Validator.

Can the validation be done in the server side? Or this can be done only in the Client side?
Ans :Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done..

How to manage pagination in a page?
Ans :Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.

What is ADO .NET and what is difference between ADO and ADO.NET?
Ans :ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate inmemory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch..
Describe the role of inetinfo.exe, aspnetisapi.dll andaspnetwp.exe
in the page loading process.
Ans :inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnetisapi.dll takes care of it by passing the request tothe actual worker process aspnetwp.exe..

What’s the difference between Response.Write() and Response.Output.Write()?
Ans :The latter one allows you to write formatted output..

What methods are fired during the page load?
Ans :Init() when the page is instantiated, Load() when the page is loaded into server memory, PreRender() the brief moment before the page is displayed to the user asHTML, Unload() when page finishes loading..

Where does the Web page belong in the .NET Framework class hierarchy?
Ans :System.Web.UI.Page .

Where do you store the information about the user’s locale?
Ans :System.Web.UI.Page.Culture .

What’s the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?
Ans : CodeBehind is relevant to Visual Studio.NET only.

What’s a bubbled event?
Ans :When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button,row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents..

Suppose you want a certain ASP.NET function executed on MouseOver over a
certain button. Where do you add an event handler?
Ans :It’s the Attributesproperty, the Add function inside that property. So
btnSubmit.Attributes.Add("onMouseOver","someClientCode();") A simple”Javascript:ClientCode();” in the button control of the .aspx page will attach the handler (javascript function)to the onmouseover event..

What data type does the RangeValidator control support?
Ans :Integer,String and Date..
Where would you use an iHTTPModule, and what are the limitations of any
approach you might take in implementing one?
Ans :One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre and postprocessing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module..

Explain what a diffgram is and a good use for one?
Ans :A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order..

What is datagrid?
Ans :The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professionallooking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data..

What’s the difference between the System.Web.UI.WebControls.DataGrid and and System.Windows.Forms.DataGrid?
Ans :The Web UI control does not inherently support masterdetail data structures. As with other Web server controls, it does not support twoway data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.

How do you customize the column content inside the datagrid?
Ans : If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.

How do you apply specific formatting to the data inside the cells?
Ans :You cannot specify formatting for columns generated when the grid’s AutoGenerateColumns property is set to true, only for bound or template columns. To format, set the column’s DataFormatString property to a stringformatting expression suitable for the data type of the data you are formatting.

How do you hide the columns?
Ans :One way to have columns appear dynamically is to create them at design time, and then to hide or show them as needed. You can do this by setting a column’s Visible property.

How do you display an editable dropdown list?
Ans : Displaying a dropdown list requires a template column in the grid. Typically, the ItemTemplate contains a control such as a databound Label control to show the current value of a field in the record. You then add a dropdown list to the EditItemTemplate. In Visual Studio, you can add a template column in the Property builder for the grid, and then use standard template editing to remove the default TextBox control from the EditItemTemplate and drag a DropDownList control into it instead. Alternatively, you can add the template column in HTML view. After you have created the template column with the dropdown list in it, there are two tasks. The first is to populate the list. The second is to preselect the appropriate item in the list — for example, if a book’s genre is set to “fiction,” when the dropdown list displays, you often want “fiction” to be preselected.

How do you check whether the row data has been changed?
Ans :The definitive way to determine whether a row has been dirtied is to handle the changed event for the controls in a row. For example, if your grid row contains a TextBox control, you can respond to the control’s TextChanged event. Similarly, for check boxes, you can respond to a CheckedChanged event. In the handler for these events, you maintain a list of the rows to be updated. Generally, the best strategy is to track the primary keys of the affected rows. For example, you can maintain an ArrayList object that contains the primary keys of the rows to update..
What do you know about .NET assemblies?
Ans: Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.

What’s the difference between private and shared assembly?
Ans : Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name..

What’s a strong name?
Ans :A strong name includes the name of the assembly, version number, culture identity, and a public key token..

How can you tell the application to look for assemblies at the locations other than its own install?
Ans :Use the directive in the XML .config file for a given application.
should do the trick. Or you can add additional search paths in the Properties box of the deployed application..

How can you debug failed assembly binds?
Ans :Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched..

Where are shared assemblies stored?
Ans :Global Assembly Cache..

How can you create a strong name for a .NET assembly?
Ans :With the help of Strong Name tool (sn.exe)..

Where’s global assembly cache located on the system?
Ans :Usually C:\winnt\assembly or C:\windows\assembly..

Can you have two files with the same file name in GAC?
Ans :GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to coexist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0..
What is delay signing?
Ans :Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development..

What’s the difference between codebased security and rolebased security? Which one is better?
Ans :Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications. Rolebased security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. There’s no better, or 100% thumbsup approach, depending on the nature of deployment, both codebased and rolebased security could be implemented to an extent..
How can you work with permissions from your .NET application?
Ans :You can request permission to do something and you can demand certain permissions from other apps. You can also refuse permissions so that your app is not inadvertently used to destroy some data..

How can C# app request minimum permissions?
Ans :Using System.Security.Permissions;
[assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)].

What’s a code group?
Ans :A code group is a set of assemblies that share a security context..

What’s the difference between authentication and authorization?
Ans :Authentication happens first. You verify user’s identity based on credentials. Authorization is making sure the user only gets access to the resources he has credentials for..

What are the authentication modes in ASP.NET?
Ans :None, Windows, Forms and Passport..

Are the actual permissions for the application defined at runtime or compiletime?
Ans :The CLR computes actual permissions at runtime based on code group membership and the calling chain of the code..

Explain the differences between Serverside and Clientside code?
Ans :Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesn’t have some of the functionality like sockets, uploading, etc. For these you have to make a custom component usually in VB or VC++. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Download time, browser compatibility, and visible code since JavaScript and VBScript code is included in the HTML page, then anyone can see the code by viewing the page source. Also a possible security hazards for the client computer..
Should validation (did the user enter a real date) occur serverside or clientside? Why?
Ans :Clientside validation because there is no need to request a server side date when you could obtain a date from the client machine..

What does the "EnableViewState" property do? Why would I want it on or off?
Ans :Enable ViewState turns on the automatic state management feature that enables server controls to repopulate 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. For example, if you are binding a control to data on every round trip (as in the datagrid example in tip #4), then you do not need the control to maintain it’s view state, since you will wipe out any repopulated data in any case. ViewState is enabled for all server controls by default. To disable it, set the EnableViewState property of the control to false..

Can you give an example of what might be best suited to place in the ApplicationStart and SessionStart subroutines?
Ans :The ApplicationStart event is guaranteed to occur only once throughout the lifetime of the application. It’s a good place to initialize global variables. For example, you might want to retrieve a list of products from a database table and place the list in application state or the Cache object. SessionStateModule exposes both SessionStart and SessionEnd events..

What are ASP.NET Web Forms? How is this technology different than what is available though ASP?
Ans :Web Forms are the heart and soul of ASP.NET. Web Forms are the User Interface (UI) elements that give your Web applications their look and feel. Web Forms are similar to Windows Forms in that they provide properties, methods, and events for the controls that are placed onto them. However, these UI elements render themselves in the appropriate markup language required by the request, e.g. HTML. If you use Microsoft Visual Studio .NET, you will also get the familiar draganddrop interface used to create your UI for your Web application..

How does VB.NET/C# achieve polymorphism?
Ans :By using Abstract classes/functions..

Can you explain what inheritance is and an example of when you might use it?
Ans :Inheritance is a fundamental feature of an object oriented system and it is simply the ability to inherit data and functionality from a parent object. Rather than developing new objects from scratch, new code can be based on the work of other programmers, adding only new features that are needed..

What’s an assembly?
Ans :Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly..

Describe the difference between inline and code behind which is best in a loosely coupled solution?
Ans :ASP.NET supports two modes of page development: Page logic code that is written inside "script runat=server" blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked "behind" the .aspx file at run time..

Explain what a diffgram is, and a good use for one?
Ans :A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order..
Where would you use an iHTTPModule, and what are the limitations of anyapproach you might take in implementing one?
Ans :One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre and postprocessing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a custom HTTP module..

In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?
Ans :Every Page object (which your .aspx page is) has nine events, most of which you will not have to worry about in your day to day dealings with ASP.NET. The three that you will deal with the most are: PageInit, PageLoad, PagePreRender..

Which method do you invoke on the DataAdapter control to load your generated dataset with data?
Ans :System.Data.Common.DataAdapter.Fill(System.Data.DataSet);
If my DataAdapter is sqlDataAdapter and my DataSet is dsUsers then it is called this way:
sqlDataAdapter.Fill(dsUsers);.

How can you provide an alternating color scheme in a Repeater control?
Ans :AlternatingItemTemplate Like the ItemTemplate element, but rendered for every other row (alternating items) in the Repeater control. You can specify a different appearance for the AlternatingItemTemplate element by setting its style properties..

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
Ans :You must set the DataMember property which Gets or sets the specific table in the DataSource to bind to the control and the DataBind method to bind data from a source to a server control. This method is commonly used after retrieving a data set through a database query..

What method do you use to explicitly kill a user’s session?
Ans :The Abandon method destroys all the objects stored in a Session object and releases their resources. If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.
Syntax: Session.Abandon .

How do you turn off cookies for one page in your site?
Ans :Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the user’s hard disk when a session ends.

No comments: