Net Framework Faqs

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Net Framework Faqs as PDF for free.

More details

  • Words: 3,916
  • Pages: 14
.NET Framework FAQs The following are commonly asked questions related to .NET Framework.

1. What is .NET? 2. What platforms does .NET run on? 3. What is the CLI? Is it the same as the CLR? 4. What is IL? 5. What versions of .NET and when they were released? 6. What's the major additon in the latest versions of .NET 3.5? 7. What is C#? 8. What does 'Managed code' mean in the .NET? 9. What is an assembly? 10. What are different types of Assemblies? 11. What is the difference between a namespace and an assembly name? 12. What is meant by un-safe code? 13. What is the difference between Unmanaged and Unsafe code? 14. What are the shortcomings of MS.NET platform? 15. Can I use the Win32 API from a .NET Framework program? 16. What is serialization in .NET and what are the ways to control serialization? 1. What is .NET? .NET is a general-purpose software development platform, similar to Java. At its core is a virtual machine (called as CLR) that turns intermediate language (IL) into machine code. High-level language compilers for C#, VB.NET and C++ are provided to turn source code into IL. C# is a new programming language, very similar to Java. An extensive class library is included, featuring all the functionality one might expect from a contempory development platform - windows GUI development (Windows Forms), database access (ADO.NET), web development (ASP.NET), web services, XML etc.

2. What platforms does .NET run on? Currently, it is supported on Windows 98, Windows 2000/2003, Windows XP and Windows Vista. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed. .NET Compcat Framework runs on Windows CE or Windows Mobile. Mono is an open source project to provide .Net on Linux.

3. What is the CLI? Is it the same as the CLR? The CLI (Common Language Infrastructure) is the definiton of the fundamentals of the .NET framework - the Common Type System (CTS), metadata, the Virtual Execution Environment (VES) and its use of intermediate language (IL), and the

support of multiple programming languages via the Common Language Specification (CLS). The CLR (Common Language Runtime) is Microsoft's primary implementation of the CLI. Other implementations are; the .NET Compact Framework for mobile devices, non-Microsoft CLI implementations like Mono and DotGNU Portable.NET.

4. What is IL? IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL during development. The IL is then converted to machine code at runtime by a Just-In-Time (JIT) compiler. Just like how Java programs are converted to Bytecode, C# and VB.NET code is converted to IL.

5. What versions of .NET and when they were released? Microsoft first announced .NET in June,2000. The following were the offical releases of .NET. • • • • •

.NET .NET .NET .NET .NET

1.0 1.1 2.0 3.0 3.5

was was was was was

relased relased relased relased relased

in in in in in

Feb,2002 Apr,2003 Nov,2005 Nov,2006 Nov,2007

The following table shows ASP.NET and C# versions along with .NET versions. .NET ASP.NET C# 1.0

1.0

1.0

1.1

1.1

1.1

2.0

2.0

2.0

3.5

3.0

3.0 3.5

6. What's the major additon in the latest versions of .NET 3.5? LINQ (Language Integrated Query) is a new way to access database, xml documents and collections. It enables programmers to access all data sources with expressions in C# and VB.NET. For example, we can access database without using any SQL using C# or VB.NET expressions.

7. What is C#? C# is a new language designed by Microsoft to work with the .NET framework. In their "Introduction to C#" whitepaper, Microsoft describe C# as follows: "C# is a simple, modern, object oriented, and type-safe programming language derived from

C and C++. C# (pronounced “C sharp”) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++." C# (or VB.NET) can be used to develop all types of applications - Console, Windows, Web, Web Services and Mobile.

What does 'Managed code' mean in the .NET? The .NET framework provides several core run-time services to the programs that run within it - for example exception handling, memory management and security. For these services to work, the code must provide a minimum level of information to the runtime. Such code is called managed code. Managed data: This is data that is allocated and freed by the .NET runtime's garbage collector.

9. What is an assembly? 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. An assembly may be either a .EXE or .DLL file. It contains code that the common language runtime executes.

10. What are different types of Assemblies? Assemblies are classified as private assemblies and global assemblies. Private assemblies are simple and copied to bin directory of the application that is using it. Shared assemblies (also called as gobal assemblies) are copied to a single location called GAC (Global assembly cache). Hence, shared assemblies are not copied in the private folders of each calling application. Each shared assembly has a four part name including its name, version, public key token and culture information. The public key token and version information makes it almost impossible for two different assemblies with the same name or for two similar assemblies with different version to mix with each other.

11. What is the difference between a namespace and an assembly name? A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. The .NET Framework

uses a hierarchical naming scheme for grouping types into logical categories of related functionality. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

12. What is meant by un-safe code? By un-safe code, it means that the managed program can access the memory address using pointers. There are two points to remember here: • •

Un-safe code is different from un-managed as it is still managed by the CLR You still can not perform pointer arithmetic in un-safe code.

13. What is the difference between Unmanaged and Unsafe code? Un-managed code runs outside the Common Language Runtime (CLR) control while the unsafe code runs inside the CLR’s control. Both un-safe and un-managed codes may use pointers and direct memory addresses.

14. What are the shortcomings of MS.NET platform? The foremost short coming of .NET platform is that it is still the propriety of Microsoft. It is more coupled with the Microsoft Windows operating system and is implemented only on Microsoft Windows successfully. MS.NET desktop applications can run only on Microsoft Windows, Web based applications and web services can only be deployed on Microsoft Internet Information Server (IIS). Since, dot net framework contains a lot of utilities, components, and framework class libraries, the size of downloadable framework is quite large (25MB compared to 5MB size of JVM). The managed .Net applications are somewhat slower to start and run than the traditional Win32 applications. The compiled code of .Net managed applications is easier to de-compile back to the source code.

15. Can I use the Win32 API from a .NET Framework program? Using platform invoke it's possible. .NET Framework programs can access native code libraries by means of static DLL entry points. Here is an example of C# calling the Win32 MessageBox function: using System; using System.Runtime.InteropServices; class MainApp { [DllImport("user32.dll", EntryPoint="MessageBox")] public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);

}

public static void Main() { MessageBox(0, "This is PInvoke in operation!", ".NET", 0 ); }

16. What is serialization in .NET and what are the ways to control serialization? Serialization is the process of converting an object into a stream of bytes. On the other hand Deserialization is the process of creating an object from a stream of bytes. Serialization/Deserialization is used to transport or to persist objects. Serialization can be defined as the process of storing the state of an object to a storage medium. You can serialize an object to a stream, disk, memory, over a network, and so forth. Remoting uses serialization to pass objects "By Value" from one computer or application domain to another. XML serialization serializes only public properties and fields and does not preserve Type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. As XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is also an open standard, which makes it an attractive choice too. There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.

ASP.NET FAQs The following are commonly asked questions related to ASP.NET.

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12.

What is AS.NET? Do I need to install IIS to run asp.net applications? What language do i have to have to develop asp.net applications? Is it better to write code in C# or Visual Basic? Can I hide the source code for my page? What is postback? What is viewstate? What are the main folder in an ASP.NET 2.0 application? Is possible to create an application where different pages use different languages for coding? What is single file vs. two file aspx? Can a single .ASPX contain two web forms? How do I create an ASPX page that periodically refreshes itself?

13. How can an ASP.NET application determine whether cookies are enabled in a 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30.

browser? How can ASP.NET application transmit data from one page to another? Is it possible to create a GridView that uses scrolling rather than paging? Is there any limit for query string? if means what is the maximum size? What are different layers commonly used in an Asp.Net application? What is the limit regarding cookies on the browser? What is the difference between web.config and machine.config? What are the methods you have to send control from one page to another What is the difference between Response.Redirect() and Server.Transfer() ? How can I get programmatic access to ASP.NET configuration settings? How do you ensure that user selects an option in a dropdown list? Can an application have more than one web.config file? What do you do if you have a few pages in your application that do not require authentication? What is the base class for asp.net page? What is AutoEventWireup atttribute in Page directive? What events fire when a page life cycle? What is AutoPostBack property? How is it difference from IsPostBack property? What is the use of Request.MapPath()?

1. What is ASP.NET? ASP.NET is the technology to build web applications using .NET. It is integrated into .NET. ASP.NET engine is responsible for processing .aspx file.

2. Do I need to install IIS to run asp.net applications? No. Though in production environment IIS is used, at the time of development, you can test your applications using ASP.NET Development Server, which is provided by Microsoft along with Visual Studio.NET and Visual Web Developer.

3. What language do i have to have to develop asp.net applications? You have to be reasonbly good at either C# or VB.NET as the code is written in either of them. Knowledge of SQL is a must if you have to talk to database. HTML is a must (you know it is easy to learn) and JavaScript is required if you want to write any code that executes on client. Of course you make use of Web controls, ADO.NET etc which are part of .NET Framework class library.

4. Is it better to write code in C# or Visual Basic? You can write code for your Web application in any language supported by the .NET Framework. That includes Visual Basic, C#, J#, JScript, and others. Although the languages have different syntax, they all compile to the same object code. The languages have small differences in how they support different features. For example, C# provides access to unmanaged code, while Visual Basic supports

implicit event binding via the Handles clause. However, the differences are minor, and unless your requirements involve one of these small differences, the choice of programming language is one of personal preference. Once programs are compiled, they all perform identically; that is, Visual Basic programs run just as fast as C# programs, since they both produce the same object code (Intermediate Language).

5. Can I hide the source code for my page? Server-side code is processed on the server and is not sent to the browser, so users cannot see it. However, client script is not protected; any client script that you add to your page, or that is injected into the page by server processing, is visible to users. If you are concerned about protecting your source code on the server, you can precompile your site and deploy the compiled version.

6. What is postback? 7. What is viewstate? ViewState is a mechanism to maintain state of web controls of ASP.Net pages. It is used to preserve the value of the web control between postbacks. ViewState is a hidden field maintained by ASP.Net to contain page data. You can disable viewstate for a control by setting enableviewstate prorty to false.

8. What are the main folder in an ASP.NET 2.0 application? Asp.net 2.0 provides diffent folder for diffrent purposes. The following table shows commonly used folders. Folder

Description

App_Code

Contains all .cs or .vb files. Basically it contains code files

App_Data

Contains data files like .MDF files

App_themes Contains themes created in the project

9. Is possible to create an application where different pages use different languages for coding? Yes. You can create pages with different languages. But, if you are creating source code files and putting them in the \App_Code folder to be compiled at run time, all the code in must be in the same language. However, you can create subfolders in the \App_Code folder and use subfolders to store components written in different programming languages.

10. What is single file vs. two file aspx?

Single file .aspx is where both the content and page are placed in a single .aspx file. Two file .aspx is where content (tags) is placed in .aspx file and code is placed in .aspx.cs or .aspx.vb file. Both provide same performance. The choice is mainly depending on

11. Can a single .ASPX contain two web forms? No.

12. How do I create an ASPX page that periodically refreshes itself? Most browsers recognize the following META tag as a signal to automatically refresh the page every nn seconds: <meta http-equiv="Refresh" content="nn"> nn is number of seconds. Alternatively you can use Response.AppendHeader to add header "Refresh" with appropriate interval in seconds. The following page will be refreshed for every 10 seconds. response.appendheader("refresh",10)

13. How can an ASP.NET application determine whether cookies are enabled in a browser? Determining whether cookies are enabled requires a round trip to the browser and back. The basic strategy is to return a cookie in an HTTP response and redirect to a page that checks for the cookie. <% ' Page1.aspx dim c as new HttpCookie("c1", "v1") Response.Cookies.Add (cookie) Response.Redirect ("page2.aspx") %> <% ' page2.aspx dim c as HttpCookie c = Request.Cookies("c1") if c is nothing or c.value <> "v1" then Response.Write ("Cookies are not enabled") else Response.Write ("Cookies are enabled") %>

14. How can ASP.NET application transmit data from one page to another? One way to transfer data from page to page is to use querystring as follows: <% ' Page1.aspx dim st as string = "somevalue" response.redirect("page2.aspx?value=" & st) %> <% ''page2.aspx dim st as string st = request.querystring("value") %> Another ways is to store data in SESSION variable. The following code shows it: <% '' Page1.aspx dim st as string = "somevalue" session("value") = st response.redirect("page2.aspx") %> <% ''page2.aspx dim st as string st = session("value") %>

15. Is it possible to create a GridView that uses scrolling rather than paging? With a little help from a
tag, yes. The following ASPX file displays scrolling table: <script runat=server> bind data to grid




16. Is there any limit for query string? if means what is the maximum size? Yes. But, it depends on browser. Generally 255 bytes. However it all depends on browser and os.

17. What are different layers commonly used in an Asp.Net application? There are three layers. • • •

Presentation or interface layer consiting of web forms. Business logic layer (BLL) consisting of classes do to business logic. Data Access Layer(DAL) is used to access back-ends such as SQL Server.

18. What is the limit regarding cookies on the browser? 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

19. What is the difference between web.config and machine.config? The settings made in the web.config file are applied to that particular web application only whereas the settings of machine.config file are applied to all asp.net applications on the system.

20. What are the methods you have to send control from one page to another You can use either Response.Redirect(url) or Server.Transfer(url) or Server.Execute(url).

21. What is the difference between Response.Redirect() and Server.Transfer() ? Server.Transfer() is used when redirecting to a page within the same application whereas Response.Redirect() can transfer to pages in other applications also. Response.Redirect will instruct browser to call a particular webpage.This will increase one request and one response between the client and server. From end-user's perspective, the url doesn't change in browser for Server.Transfer() but it does for Response.Redirect().

22. How can I get programmatic access to ASP.NET configuration settings? You can read, create, or modify configuration settings from within an ASP.NET application by using the ASP.NET management API. You can develop your own applications including Web applications, console applications, and scripts that use the management API. One of the classes in management API is WebConfigurationManager.

23. How do you ensure that user selects an option in a dropdown list? It can be achieved by using InitialValue property of RequiredFieldValidator control as follows.
--Select Item-- First Item Second Item

24. Can an application have more than one web.config file? Yes provided they are placed in different folders of the application. An asp.net application is a virtual directory that you make on a web server. This application will take the settings of machine.config file if a web.config file is not available in that directory. Now if you create a sub directory inside a virtual directory and place another web.config file in the sub directory then the sub directory will take the settings of the web.config file in that particular directory.

25. What do you do if you have a few pages in your application that do not require authentication? Assume you have register.aspx and forgotpassword.aspx file which do not require any authentication. But the rest of the pages in the application should be accessible only to authenticated users. Create a separate folder for register.aspx and forgotpassword.aspx called ALL.Place these pages in that folder and create the following web.config in that folder. l l l <system.web>l l

l
l l
l

26. What is the base class for asp.net page? Every asp.net page is converted to a class, which is derived from System.Web.UI.Page class. Starting from Asp.Net 2.0 partial class concept is used for code behind. So, if you create an asp.net page with name default.aspx, the following is the code generated by Visual Studio.Net. Partial Class Default Inherits System.Web.UI.Page End Class

27. What is AutoEventWireup atttribute in Page directive? When you set the value of the AutoEventWireup attribute to true, the ASP.NET runtime does not require events to specify event handlers like the Page_Load event or the Page_Init event. When you set the value of the AutoEventWireup attribute to false, you must manually hook up events to event handlers. When you set the value of the AutoEventWireup attribute to true, the ASP.NET page framework can automatically raise events. If the value of the AutoEventWireup attribute is set to false, you must override the OnInit function, and then you must add a new delegate for Page_Load event handler explicitly. The following example shows the difference between setting AutoEventWireup to true and false. Run the page by first setting AutoEventWireup to false. Click on the button. Then set AutoEventWireup to true and run again. Click on the button. You can see difference between these two.

AutoEventDemo.aspx <%@ Page Language="C#" AutoEventWireup="false" CodeFile="autoevent.aspx.cs" Inherits="all_autoevent" %>


AutoEventDemo.aspx.cs using System; public partial class AutoEventDemo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write("Page Load ");

}

} protected void Button1_Click(object sender, EventArgs e) { Response.Write("You Clicked On Button"); }

If performance is a key consideration, do not set the value of the AutoEventWireup attribute to true. The AutoEventWireup attribute requires the ASP.NET page framework to make a call to the CreateDelegate function for every ASP.NET Web Form page. Instead of using automatic hookup, you must manually override the events from the page.

28. What events fire when a page life cycle? The following major events occurs in the life cycle of a page. PreInit Init InitComplete PreLoad Load LoadComplete PreRender SaveStateComplete Render Unload For more details regarding page life cycle, see article in msdn

29. What is AutoPostBack property? How is it difference from IsPostBack property? AutoPostBack is a property to cause postback for controls (such as dropdownlist and checkbox) that otherwise do not cause postback. Set this property to true to make dropdownlist to cause postback when user selects a diffent item in the dropdownlist. IsPostBack is a property of Page class,which returns true if page is called because of postback.

30. What is the use of Request.MapPath()?

Request.MapPath() is used to convert virtual path to physical path. Virtual path is path understood by your web server. For example, web server understands /photo/logo.jpg. But that is not understood by OS so convert this to physical path using Request.MapPath(). For example FileUpload control's SaveAs() method expects physical path so the following converts virtual path to physical path. FileUpload1.SaveAs( Request.MapPath("photos/logo.jpg"));

Related Documents

Net Framework Faqs
November 2019 22
Net Framework
December 2019 46
Net Framework
May 2020 15
Net Framework
June 2020 17
Dot Net Faqs Shiva
November 2019 11
Dot Net Faqs
November 2019 22