Asp.Net Interview Questions (Part-1)
What are the types of ASP Objects?
You can create various type of object in ASP
- Response Object
- Application Object
- Request Object
- Session Object
- Server Object
- Error Object
- FileSystem Object
- File Object
- ADO Object
- Drive Object
List all different types of directives in Asp.Net?
- @ Assembly
- @ Control
- @ Implements
- @ Import
- @ Master
- @ MasterType
- @ OutputCache
- @ Page
- @ PreviousPageType
- @ Reference
- @ Register
What's the use of Response.Output.Write()?
Response.output.write() is used to display the formatted text.
Can you programmatically access IIS configuration settings?
Yes. By using ASP or scripts, you can create your own applications for remotely administering your IIS server. You can use Active Directory Service Interfaces (ADSI), WMI, or COM interfaces to configure IIS programmatically.
Can you have a web application running without web.Config file?
Yes. You can run asp.net application without web.config file. If you are not configure any settings in web.config file then it will take machine.config file for default configurtaons. However, it will not allow user to debug, even if you are running it in debug mode.
Which namespace is used to implement debug and trace methods?
The Systems.Diagnostics namespace includes Trace and Debug classes.
Which namespaces are used for data access?
The System.Data namespaces contain classes for accessing and managing data from diverse sources.
How can I configure ASP.NET that are running on a remote machine?
You can use Visual Studio remote debugger . Install the remote debugging components on the remote computer and launch the Remote Debugging Monitor (msvsmon.exe) when you start debugging.Where the assembly is stored in asp.net?
Private assemblies are stored in project's bin folder to use in that particular project, whereas public or shared assemblies are stored in GAC(global assembly cache) so that it is available to every project.
What is the size of the session ID?
The ASP.NET session identifier is a randomly generated number encoded into a 24-character string consisting of lowercase characters from a to z and numbers from 0 to 5.How to access session variables from any class in ASP.NET?
Access the Session via the threads HttpContext:
What are the different Session state modes available in ASP.NET?
- InProc mode - which stores session state in memory on the Web server. This is the default.
- StateServer mode - which stores session state in a separate process called the ASP.NET state service
- SQLServer mode - stores session state in a SQL Server database.
- Custom mode - which enables you to specify a custom storage provider.
- Off mode - which disables session state.
How long the items in ViewState exists?
ViewState exists till your current page exists. This includes postbacks. Viewstate become nothing once it redirects or transfer to another page.
Does viewstate expire?
No. Viewstate itself does not expire. ViewState is kept as part of the PostBack process. Since it's posted back in a form, it can be reconstituted any time. It is important to note that, ViewState is stored in the Session so if your Session expires, the ViewState will be lost.Which object encapsulates state or data of the client?
Session object.
Where is the ViewState information stored?
Viewstate is stored on page it self in encoded form. You can use hidden variable to store data that will be used only on that page and View State Data is stored in Base64 String encoded format.In which event of page cycle is the ViewState available?
ViewState is loaded into memory between init and load. In Page Init, only Partially gets loaded. In Page load,viewstate complete. So whole loading is available in Page load only.
Which is the only event provided by Cache object?
CacheItemRemoved event is the only event provided by Cache object.
Which delegate can be used to notify the application when items are removed from the cache?
onRemoveCallback is used to notify the application when items are removed from the cache.
How can we prevent browser from caching an ASPX page?
Response.Cache.SetNoStore();
What is the difference between page-level caching and fragment caching?
Page-level caching refers to the cache an entire page and the Fragment caching refers to the portion of a webpage such as caching User ControlsHow to open a page in a new window?
You can use a Javascript in code behind to open a page in a new window.
What is the default timeout for a Cookie?
The default Expires value for a cookie is not a static time, but it creates a Session cookie. Setting the Expires property to MinValue makes this a session Cookie , which is its default value. This will stay active until the user closes their browser/clears their cookies. You can override this as required.How to turn off cookies for a page?
You don't have to change anything in your ASP.NET application to enable cookieless sessions, except the following configuration setting in web.config fileWhat is the default timeout for a Cookie?
The default Expires value for a cookie is not a static time, but it creates a Session cookie. Setting the Expires property to MinValue makes this a session Cookie , which is its default value. This will stay active until the user closes their browser/clears their cookies. You can override this as required.How to turn off cookies for a page?
You don't have to change anything in your ASP.NET application to enable cookieless sessions, except the following configuration setting in web.config file.How would you create a permanent cookie?
Set its Expires property equal to DateTime.maxValue , that means cookies never Expires.How to turn off cookies for a page?
Cookie.Discard Property when set true will instruct the client application not to save the Cookie on the user's hard disk when a session ends.
What are ASP.NET Page Life Cycle Events?
- PreInit
- Init
- InitComplete
- PreLoad
- Load
- Control events
- LoadComplete
- PreRender
- PreRenderComplete
- SaveStateComplete
- Render
- Unload
How can you identify that the Page is Post Back?
Page object has an "IsPostBack" property, which can be checked to know that is the page posted back to server or not.Which method is used to post a Web page to another Web page?
The Respose.Redirect method is used to post a page to another page.What is the difference between a page theme and a global theme?
Page theme applies to a particular web pages of the project. It is stored inside a subfolder of the App_Themes folder while Global theme applies to all the web applications on the web server. It is stored inside the Themes folder on a Web server.How do we assign page specific attributes?
Page attributes are specified using the @Page directive.
What events will occur when a page is loaded?
- Page_PreInit
- Page_Init
- Page_InitComplete
- Page_PreLoad
What is Role-based security?
Role-based security allows you to partition your web site according to the "role" of the user.
Which method do you use to kill explicitly a user session?
- Session.Abandon()
- Session.Remove() - It will kill session for the specific user.
- Session.Clear() - To remove all keys with the session as well as you can also use it to remove specific keys from the session.
Is it possible to create web application with both webforms and mvc?
Yes. You have to include below mvc assembly references in the web forms application to create hybrid application.
What is RedirectPermanent in ASP.Net?
The Response.RedirectPermanent() method performs a permanent redirection from a requested URL to a specified URL.You can use RedirectPermanent if the resource has been moved permanently and will no longer be accessible in its previous location. Most browsers will cache this response and perform the redirect automatically without requesting the original resource again.
What are the advantages of Passport authentication?
The advantages of Passport authentication are that the user doesn't have to remember separate user names and passwords for various Web sites and that the user can maintain his or her profile information in a single location. There is no real-time, server-to-server communication between participating Web sites and the central .NET Passport servers.- Asp.Net Interview Questions (Part-2)
- Advantages of ASP.NET Web Development
- What is IIS - Internet Information Server
- What is Virtual Directory
- What is HttpHandler
- Page Directives in Asp.Net
- What is a postback
- What is IsPostBack
- What is global.asax
- Difference between Machine.config and web.config
- Difference between HTML control and Web Server control
- What is Query String
- Difference between Authentication and Authorization
- How to secure Connection Strings
- What is ASP.Net tracing
- Passing values between Asp.Net pages
- Differentiate between client side validation and server side validation
- How to Get host domain from URL
- Adding a Favicon To Your Website
- Asp.Net Textbox value in Javascript
- AutoEventWireup attribute in ASP.NET
- Can I use multiple programming languages in a ASP.net Web Application?
- Difference: Response.Write and Response.Output.Write
- How many web.config files can I have in an application?
- What is Protected Configuration in asp.net?
- Static variables, what is their life span?
- Difference between ASP Session and ASP.NET Session?
- What does mean Stateless?
- What is the Difference between session and caching?
- What are different types of caching using cache object of ASP.NET?
- Which method is used to remove the cache object?
- How many types of Cookies are available in ASP.NET?
- What is Page Life Cycle in ASP.net?
- What is the code behind and Inline Code in Asp.Net?
- What is master page in ASP.NET?
- Can you change a Master Page dynamically at runtime?
- What is cross-page posting in ASP.NET?
- How to redirect a page in asp.net without performing a round trip ?
- How to register custom server control on ASP.NET page?
- How do you validate Input data in Asp.Net?
- What's the difference between ViewData and ViewBag?
- Difference between Response.Redirect and Server.Transfer
- What is the function of the CustomValidator control?
- Define RequiredFieldValidator?
- Difference between custom control and user control
- Difference between Label and Literal control in ASP.Net
- What are the major events in Global.Asax file?
- What is Event Bubbling in asp.net ?
- What is Delay signing?
- What is the difference between in-proc and out-of-proc?
- What is the difference between POST and GET?
- A potentially dangerous Request.Form value was detected from the client