Top 50 Asp.net Interview Questions
Q1. Is There A Method Similar To Response.Redirect That Will Send Variables To The Destination Page Other Than Using A Query String Or The Post Method?
Server.Trfer preserves the contemporary web page context, so that inside the target web page you could extract values and such. However, it is able to have aspect consequences; because Server.Trfer doesnt' undergo the browser, the browser doesn't update its history and if the person clicks Back, they go to the web page preceding to the source page.
Another way to pass values is to use some thing like a LinkButton. It posts again to the supply page, wherein you can get the values you need, placed them in Session, and then use Response.Redirect to trfer to the target page. (This does bounce off the browser.) In the target web page you could study the Session values as required.
Q2. When Do You Use Executereader, Executenonquery, Executescalar Methods?
If the command or saved manner that is being done returns a hard and fast of rows, then we use ExecuteReader method.
If the command or stored technique that is being accomplished returns a unmarried value then we use ExecuteScalar technique.
If the command or saved method plays INSERT, DELETE or UPDATE operations, then we use ExecuteNonQuery approach.
ExecuteNon Query technique returns an integer specifying the quantity of rows inserted, deleted or up to date.
Q3. What Is Postback?
PostBack is the call given to the manner of filing an ASP.NET page to the server for processing. PostBack is done if sure credentials of the web page are to be checked against some resources (including verification of username and password the usage of database). This is something that a customer machine is not in a position to perform and for that reason those details ought to be 'published lower back' to the server.
Q4. What Is Three Tier Architecture?
Three tier architecture usually consists of a patron, server and “agent” among them. The agent is answerable for collecting the outcomes and returning a single reaction to the agent. Such architecture will increase performance, reusability and scalability of the utility.
Q5. What Is Service Oriented Architecture?
Service oriented structure is primarily based on services. Service is a unit of some mission performed by means of a service company with a view to fulfill the consumer.
Q6. What Is Reflection?
All .NET compilers produce metadata approximately the kinds described in the modules they produce. This metadata is packaged along side the module (modules in flip are packaged together in assemblies), and may be accessed by using a mechanism called reflection. The System.Reflection namespace incorporates training that may be used to interrogate the types for a module/assembly.
Using mirrored image to get entry to .NET metadata may be very just like using ITypeLib/ITypeInfo to get admission to kind library records in COM, and it's miles used for comparable purposes - e.G. Determining records kind sizes for marshaling data throughout context/system/system barriers.
Reflection also can be used to dynamically invoke methods (see System.Type.InvokeMember ) , or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).
Q7. Can We Do Database Operations Without Using Any Of The Ado.Internet Objects?
No,
its by no means feasible.
Q8. Why Cannot We Use Multiple Inheritance And Garbage Collector Paralelly In .Internet?
.Net does not guide the mutiple inheritance, possibly you could talk approximately multi-stage inheritance.
In the later case, if a category is inherited from every other class, at the time of creating example, it will manifestly supply a call to its base magnificence constructor (ie bottom - pinnacle technique). Like smart the constructor execution is takes location in pinnacle down approach (ie. Base magnificence constructor is carried out and the derived class constructor is accomplished).
So for GC, it'll gather most effective while an object does not have any reference. As we see previously, the derived is built based on base elegance. There is a reference is ready to be. Obviously GC can not be gathered.
Q9. What Are The Different Row Versions Available In Table?
There are 4 sorts of Rowversions.
Current:
The current values for the row. This row model does not exist for rows with a RowState of Deleted.
Default :
The row the default version for the present day DataRowState. For a DataRowState value of Added, Modified or Current, the default version is Current. For a DataRowState of Deleted, the model is Original. For a DataRowState value of Detached, the version is Proposed.
Original:
The row contains its unique values.
Proposed:
The proposed values for the row. This row model exists for the duration of an edit operation on a row, or for a row that isn't always a part of a DataRowCollection.
Q10. When Do You Absolutely Have To Declare A Class As Abstract (as Opposed To Free-willed Educated Choice Or Decision Based On Uml Diagram)?
When as a minimum one of the techniques within the elegance is summary. When the elegance itself is inherited from an summary class, however not all base summary strategies were over-ridden.
Q11. What Is Msil, And Why Should Developers Need An Appreciation Of It If At All?
MSIL is the Microsoft Intermediate Language. All .NET compatible languages gets transformed to MSIL. MSIL also permits the .NET Framework to JIT bring together the assembly at the set up computer.
Q12. Which Command Using Query Analyzer Will Give You The Version Of Sql Server And Operating System?
SELECT SERVERPROPERTY ('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('version').
Q13. How To Change The Page Title Dynamically?
<TITLE id="Title1" runat =server></TITLE>
VB.NET
'Declare Protected WithEvents Title1 As System.Web.UI.HtmlControls. HtmlGenericControl
'In Page_Load Title1.InnerText ="Page 1"
C#
//Declare protected System.Web.UI.HtmlControls.HtmlGenericControl Title1 ;
//In Page_Load Title1.InnerText ="Page 1" ;
Q14. What Is Boxing And Unboxing?
Boxing is implicit conversion of ValueTypes to Reference Types (Object). UnBoxing is specific conversion of Reference Types (Object) to its equivalent ValueTypes. It calls for type-casting.
Q15. Difference Between Sqlcommand And Sqlcommandbuilder?
SQLCommand is used to execute all kind of SQL queries like DML(Insert, replace,Delete) & DDL like(Create table, drop desk and so forth),
SQLCommandBuilder item is used to build & execute SQL (DML) queries like select, insert, update & delete.
Q16. What Is An Asssembly Qualified Name? Is It A Filename? How Is It Different?
An meeting certified name is not the filename of the assembly; it is the internal name of the assembly blended with the assembly model, culture, and public key, therefore making it particular.
E.G. (""System.Xml.XmlDocument, System.Xml, Version=1.0.3300.0, Culture=impartial, PublicKeyToken=b77a5c5 61934e089"").
Q17. What Is The Use Of Jit ?
JIT (Just - In - Time) is a compiler which converts MSIL code to local code, Because the common language runtime resources a JIT compiler for each supported CPU structure, builders can write a fixed of MSIL that can be JIT-compiled and run on computers with extraordinary architectures. However, your controlled code will run most effective on a specific working device if it calls platform-unique local APIs, or a platform-precise elegance library.
JIT compilation takes into account the fact that a few code might by no means get called at some stage in execution. Rather than the usage of time and memory to convert all of the MSIL in a portable executable (PE) document to native code, it converts the MSIL as wanted at some stage in execution and stores the ensuing native code so that it's miles accessible for next calls. The loader creates and attaches a stub to every of a type's methods while the sort is loaded. On the preliminary call to the technique, the stub passes manage to the JIT compiler, which converts the MSIL for that method into native code and modifies the stub to direct execution to the location of the native code. Subsequent calls of the JIT-compiled approach proceed directly to the local code that turned into formerly generated, reducing the time it takes to JIT-compile and run the code.
Q18. How Does Vb.Net/c# Achieve Polymorphism?
Polymorphism is completed via digital, overloaded, overridden techniques in C# and VB.NET.
Q19. Will Finally Block Get Executed If The Exception Had Not Occurred?
Yes.
Q20. How Can I Ensure That Application-stage Variables Are Not Updated By More Than One User Simultaneously?
Use the HttpApplicationState's Lock and UnLock strategies.
Q21. Give An Example That Shows How To Execute A Stored Procedure In Ado.Net?
The use of (SqlConnection ConnectionObject = new SqlConnection()) //Specify the name of the saved system to execute and the Connection Object to apply.
SqlCommand CommandObject = new SqlCommand("StoredProcedureName", ConnectionObject);
//Specify the SQL Command type is a stored process
CommandObject.CommandType = CommandType.StoredProcedure;
//Open the connection
ConnectionObject.Open();
//Execute the Stored Procedure
int RecordsAffected = CommandObject.ExecuteNonQuery();
Q22. What Are The Various Objects In Dataset ?
Dataset has a set of DataTable item in the Tables collection. Each DataTable item consists of a collection of DataRow gadgets and a set of DataColumn objects. There are also collections for the number one keys, constraints, and default values used in this table that's known as as constraint collection, and the parent and child relationships between the tables. Finally, there's a DefaultView item for every table. This is used to create a DataView object based at the desk, so that the information may be searched, filtered or otherwise manipulated at the same time as showing the records.
Q23. How Can I Specify The Relative Path For A File?
Suppose you've got following report hierarchy:
default.Aspx
Admin/login.Aspx
Misc/testpage.Aspx
And you're at the login.Aspx and need your user to navigate to the default.Aspx (or testpage.Aspx) report. Then you could use
Response.Redirect ("../default.Aspx").
Response.Redirect ("../Misc/testpage.Aspx").
Q24. How To Enable And Disable Connection Pooling?
For .NET it is enabled by using default but in case you want to simply ensure set Pooling=real inside the connection string. To disable connection pooling set Pooling=fake in connection string if it's miles an ADO.NET Connection.
If it's far an OLEDBConnection object set OLE DB Services=-four within the connection string.
Q25. Explain The Use Of Pre-compilation Tool?
ASP.NET 2.0 supplies a new utility deployment utility that permits each developers and directors to precompile a dynamic ASP.NET utility prior to deployment. This precompilation mechanically identifies any compilation issues everywhere inside the website online, as well as allows ASP.NET programs to be deployed with none source being saved on the server (one can optionally dispose of the content of .Aspx files as a part of the assemble segment), similarly defensive your intellectual assets.
Q26. Describe The Difference Between A Thread And A Process?
A Process is an instance of an walking utility. And a thread is the Execution circulate of the Process. A procedure could have more than one Thread.
When a manner starts offevolved a particular reminiscence location is allotted to it. When there's more than one thread in a method, each thread receives a reminiscence for storing the variables in it and plus they are able to get entry to to the worldwide variables which is commonplace for all of the thread.
Eg. A Microsoft Word is a Application. When you open a phrase document, an example of the Word starts and a technique is allocated to this example which has one thread.
Q27. Can You Explain What Inheritance Is And An Example Of When You Might Use It?
When you want to inherit (use the functionality of) another class.Example: With a base elegance named Employee, a Manager magnificence will be derived from the Employee base magnificence.
Q28. What Are The Different Index Configurations A Table Can Have?
A desk could have one of the following index configurations:
No indexes,
A clustered index,
A clustered index and lots of nonclustered indexes,
A nonclustered index,
Many nonclustered indexes.
Q29. Explain Assembly And Manifest?
An assembly is a collection of one or greater files and certainly one of them (DLL or EXE) includes a special metadata called Assembly Manifest. The happen is stored as binary facts and consists of information like versioning requirements for the assembly, the writer, protection permissions, and list of files forming the assembly. An assembly is created whenever a DLL is built. The occur may be regarded programmatically by way of utilizing classes from the System. Reflection namespace. The device Intermediate Language Disassembler (ILDASM) can be used for this cause. It may be launched from the command spark off or via Start> Run.
Q30. What Is Foreign Key?
A FOREIGN KEY constraint prevents any movements that might destroy links among tables with the corresponding statistics values. A overseas key in one table points to a primary key in every other desk. Foreign keys save you moves that might depart rows with foreign key values whilst there aren't any primary keys with that cost. The overseas key constraints are used to put into effect referential integrity.
Q31. Explain The Situations You Will Use A Web Service And Remoting In Projects?
Web services ought to be used if the software needs communication over a public community and require to paintings across multiple platforms. Remoting is faster relatively and as a result can be used in .Net additives while overall performance is a high priority. Few programs can also make use of BOTH web offerings and Remoting to send and get hold of statistics now not just across multiple structures but additionally among .Net applications where overall performance and velocity is a key precedence.
Q32. How To Convert Milliseconds Into Time?
VB.NET
dim ts as TimeSpan = TimeSpan.FromMilliseconds(ten thousand) Response.Write (ts.ToString ())
C#
TimeSpan ts = TimeSpan.FromMilliseconds(ten thousand);
Response.Write (ts.ToString ());
Q33. What Is The Standard You Use To Wrap Up A Call To A Web Service?
SOAP.
Q34. Can We Connect Two Dataadapters To Same Data Source Using Single Connection At Same Time?
Sure,
we can connect two dataadapters to identical datasource the use of single connection at identical time.
There is a generation in ado.Net 2.Zero known as MARS usinng Mars in connection string we are able to do it.
For eg:
cn.ConnectionString = "server=(neighborhood); database=worker; included safety=sspi; Multiple Active Result Sets=True";
Q35. How To Get The Url Of Page Dynamically?
Use Request.Url belongings.
Q36. What Methods Are Fired During The Page Load?
Init()-when the page is instantiated.
Load()-whilst the web page is loaded into server memory.
PreRender()-the short second earlier than the page is exhibited to the user as HTML.
Unload()-when web page finishes loading.
Q37. What Is Index?
An index is a physical structure containing pointers to the statistics. Indices are created in an present desk to locate rows more fast and efficaciously. It is viable to create an index on one or extra columns of a desk, and every index is given a name. The customers cannot see the indexes; they may be just used to hurry up queries. Effective indexes are one of the quality approaches to improve overall performance in a database software. A desk scan takes place while there's no index to be had to help a query. In a desk experiment SQL Server examines every row in the table to meet the query consequences. Table sc are once in a while unavoidable, however on huge tables, sc have a wonderful effect on performance.
Q38. Can You Reuse A Sqlcommand Object?
Yes,
you can reset the CommandText property and reuse the SqlCommand item.
Q39. How Can We Fine Tune The Command Object When We Are Expecting A Single Row ?
Again CommandBehaviour enumeration affords two values SingleResult and SingleRow. If you are anticipating a unmarried price then bypass “CommandBehaviour.SingleResult” and the query is optimized for this reason, if you are anticipating unmarried row then pass “CommandBehaviour.SingleRow” and query is optimized in line with single row.
Q40. When Is The Use Of Update_statistics Command?
This command is basically used whilst a large processing of information has passed off. If a huge amount of deletions any change or Bulk Copy into the tables has befell, it has to replace the indexes to take those modifications into consideration. UPDATE_STATISTICS updates the indexes on these tables consequently.
Q41. What Is The Best Way To Output Only Time And Not Date?
Use DateTime as follows VB.NET
Response.Write(DateTime.Now.ToString("hh:mm:ss"))
C#
Response.Write(DateTime.Now.ToString("hh:mm:ss"));
Q42. .Internet Assembly?
This article explains .Net assembly, private and shared meeting, satellite tv for pc assemblies, aid-only meeting, ResourceManager elegance, sturdy call, worldwide meeting cache.
Q43. How To Find The Count Of Records In A Dataset?
DS.Tables["tabname"].Rows.Count;
we can get be counted of the data.
Q44. What Is Managed And Unmanaged Code?
The .NET framework provides numerous core run-time offerings to the programs that run within it - as an instance exception coping with and security. For these services to paintings, the code must provide a minimal degree of records to the runtime. I.E., code executing under the control of the CLR is referred to as controlled code. For example, any code written in C# or Visual Basic .NET is managed code. Code that runs outside the CLR is referred to as "unmanaged code." COM components, ActiveX additives, and Win32 API features are examples of unmanaged code.
Q45. How Do You Update A Dataset In Ado.Internet And How Do You Update Database Through Dataset?
Update a dataset:
Dataset ds = new dataset(); SqlDataAdapter adp = new SqlDataAdapter(Query,connection); Adp.Fill(ds); Again you could add/replace Dataset as underneath SqlDataAdapter adp1 = new SqlDataAdapter(Query1,connection); Adp1.Fill(ds);
Update database through dataset.
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter); Foreach(datarow dr in ds.Table[0].Rows) Dr[“column Name”] = “fee”; mySqlDataAdapter.Update(ds);
Q46. What Does The "enableviewstate" Property Do? Why Would I Want It On Or Off?
It allows the web page to save the users enter on a form across postbacks. It saves the server-facet values for a given manage into ViewState, that's stored as a hidden cost on the page before sending the page to the customers browser. When the web page is published back to the server the server control is recreated with the kingdom stored in viewstate.
Q47. How Do We Update And Delete Data In A Gridview? Datakeynames Property In .Internet?
The quality manner to Update or Delete a document in a GridView manage is to consist of a CheckBox column and a Submit Button.
The GridView has its own Delete and Edit capability. If the GridView is populated with information using an SqlDataSource, checkout the wizard that comes in conjunction with the SqlDataSource. It may be used to mechanically create an SQL Delete command and specify the delete parameters.
The DataKeyNames assets of the GridView is ready to a area name of the Table.
Q48. How Can We Save All Data From Dataset?
Dataset has “Accept Changes” technique, which commits all the modifications given that closing time “Accept adjustments” has been finished.
Q49. If A Base Class Has A Bunch Of Overloaded Constructors, And An Inherited Class Has Another Bunch Of Overloaded Constructors, Can You Enforce A Call From An Inherited Constructor To An Arbitrary Base C
Yes,
just place a colon, after which keyword base (parameter listing to invoke the proper constructor) inside the overloaded constructor definition inside the inherited class.
Q50. What Are The Advantages Of Using Sql Stored Procedures Instead Of Adhoc Sql Queries In An Asp.Internet Web Application?
Better Performance : As stored tactics are precompiled objects they execute quicker than SQL queries. Every time we run a SQL question, the query needs to be first compiled after which finished wherein as a saved manner is already compiled. Hence executing stored procedures is an awful lot quicker than executing SQL queries.
Better Security: For a given stored manner you could specify who has the rights to execute. You can not do the same for an SQL query. Writing the SQL statements internal our code is commonly no longer a great concept. In this manner you expose your database schema (design) in the code which may be modified. Hence maximum of the time programmers use stored methods rather than plain SQL statements.
Reduced Network Traffic : Stored Procedures reside at the database server. If you have to execute a Stored Procedure out of your ASP.NET internet application you simply specify the name of the Stored Procedure. So over the community you simply send the name of the Stored Procedure. With an SQL query you have to send all of the SQL statements over the community to the database server that could result in accelerated network visitors.

