Home  >  Article  >  Backend Development  >  asp .net interview questions and answers sharing

asp .net interview questions and answers sharing

零下一度
零下一度Original
2017-06-23 15:04:123411browse

1. The difference between ref and out

2. There are three a tags with no id, no name, and no class. How to select the second a tag and use jquert to select

<a href ="#这是第一个" </a>
<a href ="#这是第二个"> </a>
<a href ="#这是第三个"> </a>

<script>$(function){
$("a:eq(1)").attr("href");
}</script>
View Code

3, What is the difference between collections, generic collections and arrays

4, What is the difference between string and stringbuilder

The string object is immutable. Every time the string class is used, a new string object must be created in the memory, which requires allocating a In the new space, stringbuilder modifies the original string when doing string concatenation operations, which improves performance!

To put it simply, string is immutable and stringbuilder is variable-length.

5. What is the difference between webapi, webservice and wcf? Why use webapi

6, how to optimize the code

7, how to optimize the database, how to optimize the query?

8, if two people are operating a piece of data at the same time, how do you deal with it?

9, do you know about cache? How to use it?

Caching is a technology that trades space for time. In layman’s terms, it means that the data you get is stored in the memory for a period of time. During this short period of time, the server cannot To read the database, or the real data source, read the data you store in memory

asp.net The cache in Cache is mainly divided into three main types: page cache, data source cache, and custom data cache.

Data caching: Add some time-consuming entries to an object cache collection and store them in the form of key values. We can set the cache's expiration, priority, dependencies, etc. by using the Cache.Insert() method.

Specific implementation reference

10, how to handle global exception handling of? How did you capture it?

Handling exceptions through the webconfig customErrors node

  <system.web>
<!--添加customErrors节点 定义404跳转页面-->
 <customErrors mode="On">
      <error statusCode="404" redirect="/Error/Path404" />
    </customErrors>
 </system.web>
View Code

Several ways to catch exceptions

## 1. Use HttpModule to catch unhandled exceptions [Recommended]

2. Capture unhandled exceptions in Global

3. Page-level exception capture

Specific code reference

11. How do I know if this user is logged in?

Logic to verify whether the user is logged in:

           1) When the user password is logged in, remember the session. in the req in the background

      2) If the user saves the login password, remember the cookie, otherwise set the current user’s cookie to empty;

      3) Each time the user needs to go to the background When requesting, perform status check:

Does the session exist? If it exists, continue the request operation and reset the validity time of the session; , that is, it has been completed once 1);

Simple answer: You can use Session to judge, because generally speaking, you have to store the login information of each user in Session

As long as the value of Session is empty or has expired, then it can be said that the user has exited!!

12. What is reflection? Application in projects? Reflection is to dynamically obtain the assembly.
Reflection: Reflection

1) Use when the base class calls the derived class

2) Use when determining which class to call at runtime

3) During runtime, obtain module assembly class constructor attribute method information and instantiated classes,


Call constructors, properties, methods, events, and delegates Wait... After dynamically instantiating the type, you can also use reflection to perform operations on it
4) If you can determine which class to call when writing the code, then of course call it directly alright.
But in many cases (perhaps for the sake of versatility), the type that needs to be called can only be determined at runtime, so it is necessary to use reflection to obtain type-related information
To put it simply, you can use string to do whatever you want at runtime. In fact, it is a universal factory built into the .net framework.
13. How to deal with high concurrency?

14. What is npoi? If anyone uses NPOI, you can read and write WORD/EXCEL documents on a machine that does not have Office installed or a corresponding environment.
NPOI is built on POI 3.x

version, which can process

Word/Excel

documents without installing

Office

Perform read and write operations.

(2) Advantages of using NPOI 1. You can use the framework completely free

2. Contains most of the features of EXCEL (cell styles, data formats, formulas, etc.)

3. Professional technical support services (24 *7/7) (not free)
4. The file formats supported include xls, xlsx, docx.
5. Adopt an interface-oriented design architecture (you can view the namespace of NPOI.SS)
6. Support the import and export of files at the same time
7. Based on .net 2.0 and also supports xlsx and docx formats (of course also supports .net 4.0)
## 8. A large number of successful and real tests from all over the world Cases
## 9. A large number of example codes
11. You don’t need to install Microsoft’s
Office on the server. Copyright issues can be avoided.
12. It is more convenient and user-friendly than the
API of Office PIA.
13. You don’t need to spend a lot of effort to maintain
NPOI, NPOI Team will be constantly updated and improvedNPOI, absolutely cost-saving.
14. Not only can you perform operations on Excel, but you can also perform corresponding operations on doc and ppt files
Use Case : Refer to the blog park website address:

15. What are the ways to transfer values ​​between pages?

16. The format of json data transmission. If a set of data is transmitted, what is the format?

The data passed by json is passed in key/value mode. For example: { "firstName": "Brett" }

If a set of data is passed, the format as follows! !

{ "people": [

{ "firstName": "Brett", "lastName": "McLaughlin", "email": "aaaa" },

{ "firstName": "Jason", "lastName":"Hunter", "email": "bbbb"},

{ "firstName": "Elliotte", "lastName":"Harold ", "email": "cccc" }

]}

17. What is a database lock and what kind of locks are there? What is the function? how to use?

18, what is a transaction? When are transactions used? What are the pros and cons of business?

19. What is dependency injection, when is it used, and what are the benefits of using it?

20. What is socket communication?

21. What is a message queue?

Recommend a very good blog,

22, what is the working principle of ajax?

The principle of ajax
XMLHttpRequest is the core mechanism of ajax. It was first introduced in IE5 and is a technology that supports asynchronous requests. To put it simply, JavaScript can make requests to the server and process responses in a timely manner without blocking the user. Achieve no refresh effect. We can think of the server as a data interface, which returns a plain text stream. Of course, this text stream can be in XML format, Html, Javascript code, or just a string. At this time, XMLHttpRequest requests this page from the server, and the server writes the text result into the page. This is the same as the ordinary web development process. The difference is that after the client obtains the result asynchronously, it is not directly displayed on the page. , but is processed by javascript first and then displayed on the page. As for many popular ajax controls now, such as magicajax, etc., they can return other data types such as DataSet. They just encapsulate the result of this process. In essence, there is not much difference between them.

23, what is ORM?

ORM, that is, Object-Relational Mapping, its function is to make a mapping between the relational database and the business entity object. In this way, we When operating business objects, you no longer need to deal with complex SQL statements, you only need to simply operate the properties and methods of the objects.

Large ORM frameworks include EF and NHibernate. So far I have only been exposed to EF. I will summarize the specific advantages and disadvantages of EF later! !

24. Convert database rows to columns and columns to rows

25. How to optimize database queries?

26, what is the difference between convert.toint32 and int,parce?

Convert.ToInt32 converts the object class type into the int type

int.Parse is suitable for converting the string class type into the int type

(1)Convert.ToInt32 has many parameters, and Int.Parse can only convert string type.
(2)Parse converts String into int, char, double ....etc., that is, *.Parse(string). The value in the brackets must be string.

27, Briefly describe the differences between "=, ==, ===" in javascript?

=Assignment

==Compare whether it is generally equal "3"==3 //Can do type Implicit conversion, true

===Compare whether strict equality "3"===3 //Compare types first, then compare values, false

28. What is the output of the following code? Explain the reason
var a = null;
alert(typeof a);
var b;
alert(typeof b);
alert(c);

a is null and is also an object, so typeof(a) is object.

b is only declared but not initialized, so typeof(b) is undefined.

c is not defined, so alert(c) will cause an error.

29. Write javascript code to merge the two arrays and delete the second element.

Use the concat method to merge js arrays, array1.concat(array2).

To delete elements, use the splice method, splice(1,1), function prototype splice(index,count), which means to delete an element starting from array index 1, that is, delete the second element. elements.

30. Briefly describe the difference between a.Equals(b) and a==b?

Equals method compares content (whether the values ​​are equal), == compares reference addresses (whether they point to the same object).

31. How many types of return values ​​are there in enumerating ASP.NET MVC ActionResult?

Mainly include View (view), PartialView (partial view), Content (content), Json (Json string), Javascript (js script), File (file) and several other types.

The above is the detailed content of asp .net interview questions and answers sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn