ASP. NET interview questions

Source: Internet
Author: User
Asp.net interview set 1: Maintain database integrity and consistency. Do you like to use triggers or write your own business logic? Why: Use constraints (including CHECK, primary key, unique key, foreign key, and non-empty fields) as much as possible. This method is the best for efficiency. Second, use a trigger, this method ensures that no matter which business system accesses the database, the database integrity and consistency can be maintained. Finally, the self-writing business logic can be used for implementation. However, this method is the least efficient and the most complex in programming, 2: ADO. What are the main improvements to NET over ADO? Answer: ADO data is stored in the form of Recordset. ADO. NET is stored in the form of DataSet.
The Recordset allows you to access ADO. NET through continuous database connection and disconnect the database.
Compared with ADO, ADO. NET provides data sets and data adapters to facilitate distributed processing and reduce resource consumption on database servers. 3: ASP. NET compared with ASP, what are the main advances? A: asp.net can use a strong language.
The page is compiled, and the execution speed is fast, increasing security and reliability.
The Inheritance mechanism is used to support code reuse and the declarative server control is provided to reduce the number of lines of code.
Asp needs to explain that the execution speed is slow and code reuse is inconvenient. There is no debugging mechanism. 4: What is the delegate in C? Is an event a delegate? A delegate is essentially a "method interface", which is equivalent to a function pointer in C/C ++. Of course, it is safer than a function pointer and is usually used for event processing in C. Compared with JAVA, you can avoid using a large number of small-granularity anonymous classes. (However, Microsoft may use an anonymous class similar to JAVA to implement delegation, but not literally. Who knows ?) The event is not a delegate, but the nature of the event determines the parameters that can be accessed by the program logic that processes it. Therefore, the event processing logic in C # is encapsulated as delegate (a "method interface "). In fact, if you are dealing with custom events, it is also possible to use interfaces as in JAVA, but doing so in C # is generally not particularly beneficial. 5: There are several usage types of new: new Class (); Second: overwrite public new XXXX () {}. Third: the new constraint specifies that any type parameter in the generic class declaration must have a common non-parameter constructor. 6: how to copy an array to arrayList answer foreach (object o in array) arrayList. add (o); 7: datagrid. what data sources can datasouse connect to? A: [dataset, able, dataview] dataset, datatable, dataview, IList8: Overview reflection and serialization answer reflection: Assembly inclusion module, while module inclusion type, type also contains members. Reflection provides encapsulated assembly, module, and type objects. You can use reflection to dynamically create instances of the type, bind the type to an existing object, or obtain the type from an existing object. Then, you can call a method of the type or access its fields and attributes. Answer serialization: serialization is the process of converting an object into a format that is easy to transmit. For example, you can serialize an object and Use HTTP to transmit the object between the client and the server over the Internet. At the other end, deserialization reconstructs the object from the stream. 9: Overview of o/r mapping principles answer reflection, configure ing of classes in database tables 10: Class Members have () accessible forms answer accessibility: public, protected, private, internal11: What are the features of a class modified with sealed? Answer: The sealed modifier is used to prevent other classes from being derived from the modified class. If a sealed class is specified as the base class of another class, a compile-time error occurs. The sealed class cannot be an abstract class at the same time.
The sealed modifier is mainly used to prevent unintentional derivation, but it can also promote some runtime optimization. Specifically, because the sealed class will never have any derived class, the call to the virtual function Member of the sealed class instance can be converted to a non-virtual call for processing. 11: List ADO. NET, and briefly describe connection, command, dataReader, dataAdapter, dataset... 12: run the following code: String strTemp = "abcdefg"; Int I System. text. encoding. default. getBytes (strTemp ). length; Int j = strTemp. length; Q: I = (14); j = (11) I = (14); j = (11) Chinese two bytes 13: C, string str = null and string str = "". Try to use text to describe the differences. (Key Points: detailed memory space allocation) Answer string str = null: no memory space is allocated, and string str = "" is used to allocate a memory space of a null string. 14. Overview of remoting and webservice in. NET and its practical application. Answer: for remote logical calls, The remoing interface can only be used in. net. 15: What is code-behind? A. aspx and cs code hiding. 16: overview of the three-tier structure system
A: presentation layer data layer business layer 17: use. net as a B/S structure system. How many layers of structure do you use for development? What are the relationships between each layer and why do you need to layer them like this?
A: Generally, it is three layers.
Data access layer, business layer, and presentation layer.
The data access layer adds, queries, and modifies databases.
The business layer is generally divided into two layers. The business apparent layer communicates with the presentation layer, and the business rule layer Implements user password security.
The presentation layer adds a form to interact with users, for example, users.
Advantages: clear division of labor, clear organization, easy debugging, and scalability.
Disadvantage: increase costs. 18: What is the user control in ASP.net? A: The user control is. the ascx extension can be dragged to different pages for calling to save code. for example, login may be available on multiple pages and can be used as a user control, however, one problem is that the relative paths of the images in the directories after the user control is dragged to different levels will become inaccurate, and you need to adjust them by writing your own methods. 19: What is an application domain? What is regulated code? What is a strong system? What is packing and unpacking? What is overload? What are the explanations of CTS, CLS, and CLR? A: The application domain can be understood as a lightweight process. Security. Small resource occupation
Regulated code: unsafe: unmanaged code. Does not run through CLR.
Strong type system RTTI: Type Recognition System.
Packing is to convert the value type to the reference type.
Unpacking is the conversion from the reference type to the value type.
Specify parameters with the same number of unique methods or different parameter types
CTS: general language system. CLS: general language specification. CLR: Common Language Runtime Library.
Class box {
Int aa (object I)
{}
Object bb ()
{}
}
Int bb = 5
New box (). aa (bb) // boxed
Int conver = (int) new box (). zz (); // unpack
// Reload
Public void aaa (int rad)
{}
Public void aaa (int len, int bre)
{}
Public void aaa (sting str)
{} 20: Let's take a look at the XML Technology and Its Applications You know. A: xml can be used in a unified data format. XML is a good thing. It can save configurations and communicate between sites, the web service must be used.
 
21: What are common objects in ADO.net? Describe them separately. A: The Connection object is used for Connection between applications and databases.
Command can retrieve and manipulate data in the database
The DataAdapter object acts as a bridge between DataSet and the data source for retrieving and storing data
The data retrieved from the database by the DataSet object can be stored in XML format.
DataReader is a type of only-in query result. Read-Only views do not have any complex functions of DataSet.
So we can speed up data access and viewing without providing disconnected access 22: How to understand delegation? A: It is said to be equivalent to a function pointer. If a delegate is defined, the method can be called without calling the original method name.
Msdn2005 explains this as follows:
Delegate has the following features: delegate is similar to a C ++ function pointer, but it is type-safe.
The delegate allows passing methods as parameters. The delegate can be used to define the callback method.
The delegate can be linked together. For example, multiple methods can be called for an event.
The method does not need to be exactly matched with the delegate signature. 23: What is the delegate in C? Is an event a delegate? A delegate can substitute a method as a parameter into another method.
A delegate can be understood as a reference to a function.
Yes, it is a special delegate 24: Similarities and Differences between UDP connections and TCP connections. A: udp only transmits data. No matter the data is not delivered, no connection is required. tcp ensures that the data transmitted is accurate. 25: What authentication methods are required for ASP.net? What are their principles? A: Forms authentication, windows Integration authentication, etc. passport verification None26: How do processes and threads understand each other? A: The process is Lao Tzu, The thread is the son, and there is no son without Lao Tzu. A Lao Tzu can have multiple sons. A son can be another son, and a son can also be another son. 27: What is code-Behind technology. A: code separation. It is wise to write HTML code at the front end and C # code at the back end. of course, there are also scripts and class calls at the front end, which can also be written together. 28: In net, what namespaces do classes that read and write XML belong?
A: System. xml 29 explains the significance and functions of UDDI and WSDL. A: UDDI is used to register services provided by various service providers so that they can be shared. It also helps WEB service customers or web users to find the Web service.
Wsdl is web Service Description Language 30: What is SOAP and what applications are there. A: Simple Object Access Protocol (SOAP) is a Protocol used to exchange information and execute remote process calls in a distributed or distributed environment. It is an XML-based Protocol. When using SOAP, you do not need to consider any specific transmission protocol (the most commonly used HTTP protocol). You can allow any type of objects or code to communicate with each other in any language on any platform. This type of communication uses messages in XML format. For details, see
 
31: how to understand the garbage collection mechanism in. net. Answer: GC? When an object is created, it is always cleared. Otherwise, Which memory is sufficient? 32: what are common webservice call methods? Answer HTTP-get Http-post Http-soap 33 overview. NET's understanding of remoting and webservice and its practical application. Answer: for remote logical calls, The remoing interface can only be used in. net. 34: the access permissions of private, protected, public, and internal modifiers are briefly described.
A: private Members can be accessed within the class.
Protected: protects members, which can be accessed within the class and in the inheritance class.
Public: A public member. It is completely public and has no access restrictions.
Internal: accessible within the same namespace. 35: lists several methods for passing values between ASP. NET pages.
Answer. 1. Use QueryString,
Source Page
String url;
Url = "anotherwebform. aspx? Name = "+ TextBox1.Text
Response. Redirect (url); Target page
Label1.Text = Request. QueryString ["name"]; 2. Use the Session variable
Source Page
Session ["name"] = TextBox1.Text;
Session ["email"] = TextBox2.Text;
Server. Transfer ("anotherwebform. aspx"); Target page
Label1.Text = Session ["name"]. ToString ();
Label2.Text = Session ["email"]. ToString ();
Session. Remove ("name ");
Session. Remove ("email"); 3. Use Server. Transfer
Source Page code:
Public string Name
{
Get {
Return TextBox1.Text ;}
}
// Call the Server. Transfer Method
Private void button#click
(Object sender, System. EventArgs e)
{
Server. Transfer ("anotherwebform. aspx ");
} Target Page code:
Private void Page_Load
(Object sender, System. EventArgs e)
{
WebForm1 wf1;
Wf1 = (WebForm1) Context. Handler;
Label1.Text = wf1.Name;
}
36: The rules for a column are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ...... calculate the number of 30th digits and use a recursive algorithm. A: public class MainClass
{
Public static void Main ()
{
Console. WriteLine (Foo (30 ));
}
Public static int Foo (int I)
{
If (I <= 0)
Return 0;
Else if (I> 0 & I <= 2)
Return 1;
Else return Foo (I-1) + Foo (I-2 );
}
} 37: differences between override and overload
A:
The difference between override and overload. Overload means that the method name is the same. The parameters or parameter types are different and are reloaded multiple times to meet different needs.
Override is used to Override functions in the base class. To meet your needs. 38: programmatically traverse all TextBox controls on the page and assign it a string. Empty?
A:
Foreach (System. Windows. Forms. Control control in this. Controls)
{
If (control is System. Windows. Forms. TextBox)
{
System. Windows. Forms. TextBox tb = (System. Windows. Forms. TextBox) control;
Tb. Text = String. Empty;
}
} 39: How can I implement a Bubble Sorting Algorithm by programming?
A:
Int [] array = new int [*];
Int temp = 0;
For (int I = 0; I <array. Length-1; I ++)
{
For (int j = I + 1; j <array. Length; j ++)
{
If (array [j] <array [I])
{
Temp = array [I];
Array [I] = array [j];
Array [j] = temp;
}
}
} 40: To describe the implementation process of the indexer in C #, can I index data only by numbers?
A: No. Any type can be used. 41: Evaluate the values of the following expressions and write out one or more implementation methods you have come up with: 1-2 + 3-4 + ...... + M
A:
Int Num = this. TextBox1.Text. ToString ();
Int Sum = 0;
For (int I = 0; I <Num + 1; I ++)
{
If (I % 2) = 1)
{
Sum + = I;
}
Else
{
Sum = Sum-I;
}
}
System. Console. WriteLine (Sum. ToString ());
System. Console. ReadLine (); 42: In the example below
Using System;
Class
{
Public ()
{
PrintFields ();
}
Public virtual void PrintFields (){}
}
Class B:
{
Int x = 1;
Int y;
Public B ()
{
Y =-1;
}
Public override void PrintFields ()
{
Console. WriteLine ("x = {0}, y = {1}", x, y );
}
What is the output when new B () is used to create B's instance?
Answer: X = 1, Y = 0; x = 1 y =-1 43: what classes are required to read and write databases in net? What are their roles?
Answer: DataSet: data storage.
DataCommand: Execute the statement command.
DataAdapter: a collection of data for filling. 44: What authentication methods does ASP.net provide? What are their principles?
A: IIS is used for Windwos (default...
From (form) Account
Passport (key) 45: In. net, what does the accessory mean?
A: assembly. (Intermediate language, source data, resources, assembly list) 46: What is the working principle of net Remoting?
A: the server sends a process number and a program domain number to the client to determine the object location.
 
47. Based on the delegate knowledge, complete the following code snippets in the user control:
Namespace test
{
Public delegate void OnDBOperate ();
Public class UserControlBase: System. Windows. Forms. UserControl
{
Public event OnDBOperate OnNew;
PrivatevoidtoolBar_ButtonClick (objectsender, System. Windows. Forms. ToolBarButtonClickEventArgs e)
{
If (e. Button. Equals (BtnNew ))
{
// Complete the following code to call the OnNew event of the OnDBOperate delegate signature.
}
}
}
A: if (OnNew! = Null
OnNew (this, e; 48: In the SQLSERVER server, the given table table1 contains two fields: ID and LastUpdateDate. ID indicates the updated transaction number, and LastUpdateDate indicates the server time during the update, use an SQL statement to obtain the last updated transaction number.
A: Select id from table1 Where LastUpdateDate = (Select MAX (LastUpdateDate) FROM table1) 49: Based on the knowledge about thread security, analyze the following code, will deadlock occur when I> 10 of the test method is called? And briefly explain the reasons.
Public void test (int I)
{
Lock (this)
{
If (I> 10)
{
I --;
Test (I );
}
}
}
A: No deadlock will occur (but one int is passed by value, so each change is only a copy, so no deadlock will occur. But if you replace int with an object, the deadlock will occur. 50: Let's briefly discuss your understanding of the remoting and webservice technologies under the Microsoft. NET Framework and their practical applications. A: WS uses HTTP to penetrate the firewall. Remoting can improve the efficiency by using TCP/IP and binary transfer. 51: use C # to implement the following functions:
A generates an int array with a length of 100 and inserts 1-100 randomly into it, which cannot be repeated.
Answer: List L = new List ();
Random random = new Random ();
For (int I = 1; I <= 100; I ++)
{
If (L. IndexOf (I) <0)
{
L. Add (random. Next (1,100 ));
}
}
B sorts the array generated above, which must be in ascending or descending order.
Answer L. Reverse (L );
L. Sort (L); 52: Describe the error handling mechanism in. net. For example, the Exception is an object inherited from the Exception class. An exception is thrown from the problematic code area and then passed up the stack until the application processes it or the program ends.
Try
{// Execute the code, not sure whether an error will occur}
Catch
{// Error handling}
Finally
{// Execute in any case} 53: Enter the meaning of a strong name.
A: The principle of garbage collection is to determine the amount of memory to be reclaimed based on whether the reference is null and the memory occupied by the data type. to put it bluntly, a data type is required. 54: list several loop methods in c # and point out their differences
Answer for while foreach do while55: Indicate all types of base classes in. net.
Answer: object 56: specify the meaning of GAC.
Answer: Global Access cache 57: in SQL SREVER, new data is inserted into a table and how to quickly obtain the current value of the Self-increment Field
A: insert into jobs (job_desc, min_lvl, max_lvl)
VALUES ('accountant', 12,125)

58: What is a WEB control? What are the advantages of using WEB controls?
A: The web control is a control that can be executed on the server. The advantage is that it can return data with event-driven 59: Please explain ASP. In. NET, how does one perform data verification?
A. net provides several data verification controls that can be verified on the server or client. 60: What about regular expressions?
A is mainly used for string matching and is irrelevant to the specific language environment.

61: ASP. NET. How many types of controls are there? What are their differences?
Answer: Traditional Html markup of html controls
Web controls can return data, event-driven
Custom Controls are added based on the original controls
Composite controls Composite multiple child controls into a new control

62: WEB controls can activate server events. How does a server event occur and how it works? What is automatic transmission? Why use automatic transmission.
A: Execute the event by implementing the IPostBack interface. Auto-return refers to AutoPostBack. with auto-return, you can monitor client changes and return these changes to the server.

63: Can WEB controls and HTML server controls call client methods? If yes, how can I call it?
A: Yes. The server-side controls are still html-marked in html format. Therefore, client events can be executed in multiple ways: 1. control. attributes ["onclick"] = "...; ";
2. <script for = "controlName" event = "onclick"> </script>


64: ASP. What is the relationship between web pages and hidden classes in. NET?
Answer: inherited relationships

65: What is viewstate? Can it be disabled? Can all controls be disabled?
A: You can disable it all. viewstate is the hidden input, but the status of the control is recorded with the Microsoft encoding method.

66: What is the possible cause when I find that I cannot read the input data on the page? Solution
The answer may be that the event is not associated or the code is not written or read at all.
Solve code check and set breakpoint debugging

67: Explain the code execution sequence on a WEB page.
A. cs knows that OnInit () is executed first, then Page_Load is executed, and finally the specific execution event is executed.

68: Please explain what is a context object and under what circumstances the context object should be used
A: HttpContext. HttpContext is required for class calls.

69: What is the difference between forwarding and redirection?
Answer: Transfer is a forward object including HttpHandler.
Redirect is the jump

70: Please explain ASP. Differences between the buttons linkbutton imagebutton and hyperlink in. NET
A: button imagebutton transfers data back to the server.
Navigation Between hyperlinK pages
Linkbutton is mainly used to save data to the server or access the data on the server 71: Please explain. . NET multi-tier application middle-layer and layer-layer data transmission in that way. And explain the method used in your project.
Answer: This transmission method is not fixed. Many of them are DataSet and XML.

72: ASP appears. NET events cannot be triggered due to what causes?
Answer: The cause of event loss is unknown, especially when vss is used.

73: If you need to add a drop-down list box to a column in the datagride control and bind the data, how can this problem be solved?
A: use the template column to add the dropdownlist. Bind data using the code prefix method.

74: What is the difference between data binding in asp.net and traditional data binding?
More flexible and convenient answers

75: Please explain what is the difference between the Delegate-implemented event model of. net and the event model implemented using interfaces in JAVA,
Answer.

76: What is the significance of explicit implementation of interfaces?
Answer: Make sure that the HTML control is used and the WEB control is used and the difference between the two is compared.
A: The console uses an html control. If you want to interact with the server, you can add runat = server to make it a server control. However, it does not have many methods and attributes for web control, if you need to use it, use the interfaces and classes in web controls78: C. A: The interface can only contain abstract methods, cannot contain any method implementation, cannot create an interface instance, and the interface member does not have an access modifier, the interface member must be a method property event or the indexer cannot contain constant field operators or static members.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.