Top .NET Interview Questions To Look Out For In 2021
Advanced .NET Interview Questions
EXE and DLL are assembly executable modules.
EXE: It is an executable file that runs the application for which it is designed. When we build an application, an exe file is generated. Therefore the assemblies are loaded directly when we run an exe. But an exe file cannot be shared with other applications.Read More Dotnet Online Training
DLL: It stands for dynamic link library that consists of code that needs to be hidden. The code is encapsulated in this library, an application can have many DLLs and can also be shared with other applications.
Q-2: What is the difference between function and stored procedure?
| Function | Stored Procedure |
| Must return a single value | Always used to perform a specific task |
| It can only have the input parameter | It can have both input and output parameters |
| Exception handling is not possible using a try-catch block | Exception handling can be done using a try-catch block |
| A stored procedure cannot be called from a function | A function can be called from a procedure |
Q-3: List the events in the page life cycle.
Following are the events in the page life cycle:
Page_PreInit
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_PreRender
Render
Q-4: What is the code to send an email from an ASP.NET application?
1 2 3 4 5 6 7 8 | mail message = new mail();message.From = "abc@gmail.com";message.To = "xyz@gmail.com";message.Subject = "Test";message.Body = "hello";SmtpMail.SmtpServer = "localhost";SmtpMail.Send(message); |
Q-5: What are the event handlers that we have for the Global.asax file?
Application Events:
- Application_Start, Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute, Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache
Session Events:
Session_Start, Session_End
Q-6: Explain role-based security.
Role-based security is used to implement security measures based on the role assigned to the users in the organization. Then we can authorize users based on their roles in the organization. For example, windows have role-based access like user, administrators, and guests.Know More Dotnet Online Course
Q-7: What is cross-page posting?
Whenever we click on a submit button on a page, the data is stored on the same page. But if the data is stored on a different page, it is known as a cross-page posting.
Cross-page posting can be achieved by POSTBACKURL property which causes the postback.
FindControl method can be used to get the values that are posted on this page to which the page has been posted.Read More Dotnet Training
Q-8: How can we apply themes to an ASP.NET application?
We can use the web.config file to specify the themes
1 2 3 4 5 | <cofiguration><system.web><pages theme="windows"/></system.web></configuration> |
Q-9: Explain passport authentication.
During the passport authentication, it first checks the passport authentication cookie, if the cookie is not available the application redirects to the passport sign on page. Passport service then authenticates the details of the user on the sign on page and if they are valid, stores them on the client machine and then redirects the user to the requested page.
Q-10: What are ASP.NET security controls?
<asp: Login>: Provides a login capability that enables the users to enter their credentials.
<asp: LoginName>: Allows you to display the name of the logged-in user.
<asp: LoginStatus>: Displays if the user is authenticated or not.
<asp: LoginView>: provides various login views depending on the template that has been selected.
<asp: PasswordRecovery>: Emails the users the lost passwords.Know More Dotnet Online Training
Q-11: List all the templates of the Repeater control.
ItemTemplate
AlternatingItemTemplate
SeparatorTemplate
HeaderTemplate
FooterTemplate
Q-12: What is the appSettings section in the web.config file?
If we want to set the user-defined values for the whole applications, we can use the appSettings block in the web.config file. For example the code below uses the ConnectionString throughout the project for the database connection:
1 2 3 4 | <em><configuration><appsettings><add key= "ConnectionString" value="server=local; pwd=password; database=default" /></appSettings></em> |
Q-13: What is MIME?
MIME stands for multipurpose internet mail extensions, it is the extension of the e-mail protocol which lets users use the protocol to exchange files over the internet.
Servers insert the MIME header at the beginning of the web transmission. Then the clients use this header to select an appropriate ‘player’ for the type of data that the header indicates. Some of these players are built into the web browser.Read More Dotnet Online Course
Q-14: What is HTTP Handler?
Every request into an ASP.NET application is handled by a specialized component called HTTP handler. It is the most important component for handling ASP.NET application requests.
It uses different handlers to serve different files. The handler for web page creates the page and control objects, runs your code and then renders the final HTML.
Following are the default HTTP handlers for ASP.NET:
Page Handler(.aspx): Handles web pages
User Control Handler(.ascx): It handles web user control pages
Web Service Handler(.asmx): Handles web service pages
Trace Handler(trace.axd): It handles trace functionality
Q-15: What are the different types of cookies in ASP.NET?
Session Cookie: It resides on the client machine for a single session until the user logs out.Know More Dotnet Training
Persistent Cookie: Resides on the user machine for a period specified for its expiry. It may be an hour, a month or never.
Q-16: What is the difference between ExecuteScalar and ExecuteNonQuery?
| ExecuteScalar | ExecuteNonQuery |
| Returns the output value | Does not return any value |
| Used for fetching a single value | Used to execute insert and update statements |
| Does not return the number of affected rows | Returns the number of affected rows. |

Comments
Post a Comment