{"id":2098,"date":"2023-12-14T09:05:27","date_gmt":"2023-12-14T09:05:27","guid":{"rendered":"https:\/\/www.kaashivinfotech.com\/blog\/?p=2098"},"modified":"2025-07-29T12:09:30","modified_gmt":"2025-07-29T12:09:30","slug":"asp-net-interview-questions","status":"publish","type":"post","link":"https:\/\/www.kaashivinfotech.com\/blog\/asp-net-interview-questions\/","title":{"rendered":"Top 30+ ASP.Net Interview Questions &#038; Answers"},"content":{"rendered":"<p data-start=\"245\" data-end=\"548\">If you&#8217;re preparing for your first job in web development, this guide on <a href=\"https:\/\/www.wikitechy.com\/tutorials\/csharp\/csharp-interview-questions\" target=\"_blank\" rel=\"noopener\"><strong data-start=\"318\" data-end=\"361\">asp.net interview questions and answers<\/strong><\/a> will give you the edge you need. ASP.NET is a key technology for web development on the Microsoft stack, and understanding its concepts is essential to landing your first developer role.<\/p>\n<p data-start=\"550\" data-end=\"721\">Whether you&#8217;re just starting out or looking to brush up on the basics, here are <strong data-start=\"630\" data-end=\"693\">40 top asp net interview questions and answers for freshers<\/strong> with detailed explanations.<\/p>\n<h2 data-section-id=\"lqxxhc\" data-start=\"728\" data-end=\"753\">30+ ASP.NET Interview Questions and Answers<\/h2>\n<figure id=\"attachment_9515\" aria-describedby=\"caption-attachment-9515\" style=\"width: 686px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-9515\" src=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers.png\" alt=\"asp.net interview questions and answers\" width=\"686\" height=\"457\" srcset=\"https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers.png 1536w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-300x200.png 300w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-1024x683.png 1024w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-768x512.png 768w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-332x221.png 332w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-664x443.png 664w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-688x459.png 688w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-1044x696.png 1044w, https:\/\/www.kaashivinfotech.com\/blog\/wp-content\/uploads\/2023\/12\/ASP-.Net-Interview-Question-and-Answers-1400x933.png 1400w\" sizes=\"auto, (max-width: 686px) 100vw, 686px\" \/><figcaption id=\"caption-attachment-9515\" class=\"wp-caption-text\">ASP .Net Interview Question and Answers<\/figcaption><\/figure>\n<h3 data-section-id=\"lqxxhc\" data-start=\"728\" data-end=\"753\">1. What is ASP.NET?<\/h3>\n<p data-start=\"755\" data-end=\"1035\"><strong data-start=\"811\" data-end=\"822\">Answer:<\/strong><br data-start=\"822\" data-end=\"825\" \/>ASP.NET is a web application framework developed by Microsoft to allow developers to build dynamic web applications, services, and sites. It runs on the .NET framework and supports languages like C# and VB.NET.<\/p>\n<hr data-start=\"1037\" data-end=\"1040\" \/>\n<h3 data-section-id=\"1ypegzc\" data-start=\"1042\" data-end=\"1084\">2. What are the features of ASP.NET?<\/h3>\n<p data-start=\"1086\" data-end=\"1168\"><strong data-start=\"1155\" data-end=\"1166\">Answer:<\/strong><\/p>\n<ul data-start=\"1169\" data-end=\"1347\">\n<li data-start=\"1169\" data-end=\"1214\">\n<p data-start=\"1171\" data-end=\"1214\">Separation of HTML and code (code-behind)<\/p>\n<\/li>\n<li data-start=\"1215\" data-end=\"1235\">\n<p data-start=\"1217\" data-end=\"1235\">State management<\/p>\n<\/li>\n<li data-start=\"1236\" data-end=\"1265\">\n<p data-start=\"1238\" data-end=\"1265\">Rich server-side controls<\/p>\n<\/li>\n<li data-start=\"1266\" data-end=\"1309\">\n<p data-start=\"1268\" data-end=\"1309\">Strong support for XML and web services<\/p>\n<\/li>\n<li data-start=\"1310\" data-end=\"1347\">\n<p data-start=\"1312\" data-end=\"1347\">Security via Windows authentication<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"1349\" data-end=\"1352\" \/>\n<h3 data-section-id=\"1bo6jfc\" data-start=\"1354\" data-end=\"1399\">3. Explain the ASP.NET page life cycle.<\/h3>\n<p data-start=\"1401\" data-end=\"1522\"><strong data-start=\"1458\" data-end=\"1469\">Answer:<\/strong><br data-start=\"1469\" data-end=\"1472\" \/>The page life cycle includes the following stages:<\/p>\n<ol data-start=\"1523\" data-end=\"1637\">\n<li data-start=\"1523\" data-end=\"1540\">\n<p data-start=\"1526\" data-end=\"1540\">Page Request<\/p>\n<\/li>\n<li data-start=\"1541\" data-end=\"1551\">\n<p data-start=\"1544\" data-end=\"1551\">Start<\/p>\n<\/li>\n<li data-start=\"1552\" data-end=\"1571\">\n<p data-start=\"1555\" data-end=\"1571\">Initialization<\/p>\n<\/li>\n<li data-start=\"1572\" data-end=\"1581\">\n<p data-start=\"1575\" data-end=\"1581\">Load<\/p>\n<\/li>\n<li data-start=\"1582\" data-end=\"1610\">\n<p data-start=\"1585\" data-end=\"1610\">Postback Event Handling<\/p>\n<\/li>\n<li data-start=\"1611\" data-end=\"1625\">\n<p data-start=\"1614\" data-end=\"1625\">Rendering<\/p>\n<\/li>\n<li data-start=\"1626\" data-end=\"1637\">\n<p data-start=\"1629\" data-end=\"1637\">Unload<\/p>\n<\/li>\n<\/ol>\n<p data-start=\"1639\" data-end=\"1706\">Each stage gives developers a chance to handle events or load data.<\/p>\n<hr data-start=\"1708\" data-end=\"1711\" \/>\n<h3 data-section-id=\"1lmgh7c\" data-start=\"1713\" data-end=\"1751\">4. What is ViewState in ASP.NET?<\/h3>\n<p data-start=\"1753\" data-end=\"1920\"><strong data-start=\"1753\" data-end=\"1764\">Answer:<\/strong><br data-start=\"1764\" data-end=\"1767\" \/>ViewState maintains the state of controls between postbacks. It&#8217;s stored in a hidden field on the page and allows the data to persist during round trips.<\/p>\n<hr data-start=\"1922\" data-end=\"1925\" \/>\n<h3 data-section-id=\"qhkhtt\" data-start=\"1927\" data-end=\"1985\">5. What are the different types of state management?<\/h3>\n<p data-start=\"1987\" data-end=\"2000\"><strong data-start=\"1987\" data-end=\"1998\">Answer:<\/strong><\/p>\n<ul data-start=\"2001\" data-end=\"2094\">\n<li data-start=\"2001\" data-end=\"2051\">\n<p data-start=\"2003\" data-end=\"2051\">Client-side: ViewState, Cookies, Query Strings<\/p>\n<\/li>\n<li data-start=\"2052\" data-end=\"2094\">\n<p data-start=\"2054\" data-end=\"2094\">Server-side: Session, Application, Cache<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"2096\" data-end=\"2099\" \/>\n<h3 data-section-id=\"dxuso5\" data-start=\"2101\" data-end=\"2167\">6. What is the difference between ASP.NET Web Forms and MVC?<\/h3>\n<p data-start=\"2169\" data-end=\"2182\"><strong data-start=\"2169\" data-end=\"2180\">Answer:<\/strong><\/p>\n<ul data-start=\"2183\" data-end=\"2385\">\n<li data-start=\"2183\" data-end=\"2283\">\n<p data-start=\"2185\" data-end=\"2283\">Web Forms use event-driven programming; MVC uses a separation of concerns (Model-View-Controller).<\/p>\n<\/li>\n<li data-start=\"2284\" data-end=\"2340\">\n<p data-start=\"2286\" data-end=\"2340\">MVC provides better control over HTML and testability.<\/p>\n<\/li>\n<li data-start=\"2341\" data-end=\"2385\">\n<p data-start=\"2343\" data-end=\"2385\">Web Forms are ideal for rapid development.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"2387\" data-end=\"2390\" \/>\n<h3 data-section-id=\"1ryf9c8\" data-start=\"2392\" data-end=\"2432\">7. What is the use of Global.asax?<\/h3>\n<p data-start=\"2434\" data-end=\"2623\"><strong data-start=\"2434\" data-end=\"2445\">Answer:<\/strong><br data-start=\"2445\" data-end=\"2448\" \/>Global.asax (also called the ASP.NET application file) contains event handlers for application-level events like <code class=\"\" data-line=\"\">Application_Start<\/code>, <code class=\"\" data-line=\"\">Session_Start<\/code>, and <code class=\"\" data-line=\"\">Application_Error<\/code>.<\/p>\n<hr data-start=\"2625\" data-end=\"2628\" \/>\n<h3 data-section-id=\"afkvqg\" data-start=\"2630\" data-end=\"2658\">8. What is a Postback?<\/h3>\n<p data-start=\"2660\" data-end=\"2815\"><strong data-start=\"2660\" data-end=\"2671\">Answer:<\/strong><br data-start=\"2671\" data-end=\"2674\" \/>Postback is the process of submitting an ASP.NET page to the server for processing. It occurs when a form is submitted using server controls.<\/p>\n<hr data-start=\"2817\" data-end=\"2820\" \/>\n<h3 data-section-id=\"19xejgj\" data-start=\"2822\" data-end=\"2900\">9. What is the difference between Server.Transfer and Response.Redirect?<\/h3>\n<p data-start=\"2902\" data-end=\"2915\"><strong data-start=\"2902\" data-end=\"2913\">Answer:<\/strong><\/p>\n<ul data-start=\"2916\" data-end=\"3069\">\n<li data-start=\"2916\" data-end=\"2996\">\n<p data-start=\"2918\" data-end=\"2996\"><code class=\"\" data-line=\"\">Server.Transfer<\/code> transfers processing to a new page without changing the URL.<\/p>\n<\/li>\n<li data-start=\"2997\" data-end=\"3069\">\n<p data-start=\"2999\" data-end=\"3069\"><code class=\"\" data-line=\"\">Response.Redirect<\/code> sends a new request and updates the browser\u2019s URL.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"3071\" data-end=\"3074\" \/>\n<h3 data-section-id=\"tyuyvu\" data-start=\"3076\" data-end=\"3124\">10. What is the use of Session in ASP.NET?<\/h3>\n<p data-start=\"3126\" data-end=\"3285\"><strong data-start=\"3126\" data-end=\"3137\">Answer:<\/strong><br data-start=\"3137\" data-end=\"3140\" \/>Session is used to store user-specific information that needs to persist across multiple pages. It&#8217;s stored server-side and unique for each user.<\/p>\n<hr data-start=\"3287\" data-end=\"3290\" \/>\n<h3 data-section-id=\"1qciltr\" data-start=\"3292\" data-end=\"3329\">11. What is caching in ASP.NET?<\/h3>\n<p data-start=\"3331\" data-end=\"3505\"><strong data-start=\"3331\" data-end=\"3342\">Answer:<\/strong><br data-start=\"3342\" data-end=\"3345\" \/>Caching stores frequently used data in memory to reduce database hits and improve performance. Types include output caching, data caching, and fragment caching.<\/p>\n<hr data-start=\"3507\" data-end=\"3510\" \/>\n<h3 data-section-id=\"r72bmy\" data-start=\"3512\" data-end=\"3548\">12. What are ASP.NET controls?<\/h3>\n<p data-start=\"3550\" data-end=\"3750\"><strong data-start=\"3550\" data-end=\"3561\">Answer:<\/strong><br data-start=\"3561\" data-end=\"3564\" \/>ASP.NET controls are UI elements like TextBox, Button, DropDownList, etc., used to collect and display information. There are HTML controls, Web server controls, and Validation controls.<\/p>\n<hr data-start=\"3752\" data-end=\"3755\" \/>\n<h3 data-section-id=\"1bibkuy\" data-start=\"3757\" data-end=\"3828\">13. What is the difference between Web.config and Machine.config?<\/h3>\n<p data-start=\"3830\" data-end=\"3843\"><strong data-start=\"3830\" data-end=\"3841\">Answer:<\/strong><\/p>\n<ul data-start=\"3844\" data-end=\"3973\">\n<li data-start=\"3844\" data-end=\"3903\">\n<p data-start=\"3846\" data-end=\"3903\"><code class=\"\" data-line=\"\">Web.config<\/code>: Configuration for a specific application.<\/p>\n<\/li>\n<li data-start=\"3904\" data-end=\"3973\">\n<p data-start=\"3906\" data-end=\"3973\"><code class=\"\" data-line=\"\">Machine.config<\/code>: Configuration for all applications on the server.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"3975\" data-end=\"3978\" \/>\n<h3 data-section-id=\"el3ed3\" data-start=\"3980\" data-end=\"4012\">14. What are Master Pages?<\/h3>\n<p data-start=\"4014\" data-end=\"4185\"><strong data-start=\"4014\" data-end=\"4025\">Answer:<\/strong><br data-start=\"4025\" data-end=\"4028\" \/>Master Pages allow a consistent layout for multiple pages in a web application. They define placeholders and common design elements like headers and footers.<\/p>\n<hr data-start=\"4187\" data-end=\"4190\" \/>\n<h3 data-section-id=\"3xky9b\" data-start=\"4192\" data-end=\"4225\">15. What are User Controls?<\/h3>\n<p data-start=\"4227\" data-end=\"4382\"><strong data-start=\"4227\" data-end=\"4238\">Answer:<\/strong><br data-start=\"4238\" data-end=\"4241\" \/>User Controls are reusable page fragments (.ascx files) used across multiple pages. They encapsulate UI and logic, making maintenance easier.<\/p>\n<hr data-start=\"4384\" data-end=\"4387\" \/>\n<h3 data-section-id=\"o3fqz6\" data-start=\"4389\" data-end=\"4464\">16. What is the difference between Server Controls and HTML Controls?<\/h3>\n<p data-start=\"4466\" data-end=\"4479\"><strong data-start=\"4466\" data-end=\"4477\">Answer:<\/strong><\/p>\n<ul data-start=\"4480\" data-end=\"4673\">\n<li data-start=\"4480\" data-end=\"4557\">\n<p data-start=\"4482\" data-end=\"4557\">Server Controls run on the server and provide automatic state management.<\/p>\n<\/li>\n<li data-start=\"4558\" data-end=\"4673\">\n<p data-start=\"4560\" data-end=\"4673\">HTML Controls are standard HTML tags that need to be converted using <code class=\"\" data-line=\"\">runat=&quot;server&quot;<\/code> to access them server-side.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"4675\" data-end=\"4678\" \/>\n<h3 data-section-id=\"1ottdc0\" data-start=\"4680\" data-end=\"4742\">17. What is authentication and authorization in ASP.NET?<\/h3>\n<p data-start=\"4744\" data-end=\"4757\"><strong data-start=\"4744\" data-end=\"4755\">Answer:<\/strong><\/p>\n<ul data-start=\"4758\" data-end=\"4923\">\n<li data-start=\"4758\" data-end=\"4804\">\n<p data-start=\"4760\" data-end=\"4804\">Authentication confirms a user\u2019s identity.<\/p>\n<\/li>\n<li data-start=\"4805\" data-end=\"4923\">\n<p data-start=\"4807\" data-end=\"4923\">Authorization determines access levels to resources.<br data-start=\"4859\" data-end=\"4862\" \/>ASP.NET supports Windows, Forms, and Passport authentication.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"4925\" data-end=\"4928\" \/>\n<h3 data-section-id=\"yyl19s\" data-start=\"4930\" data-end=\"4956\">18. What is ADO.NET?<\/h3>\n<p data-start=\"4958\" data-end=\"5129\"><strong data-start=\"4958\" data-end=\"4969\">Answer:<\/strong><br data-start=\"4969\" data-end=\"4972\" \/>ADO.NET is a data access technology used to interact with databases. It includes classes like <code class=\"\" data-line=\"\">SqlConnection<\/code>, <code class=\"\" data-line=\"\">SqlCommand<\/code>, <code class=\"\" data-line=\"\">SqlDataAdapter<\/code>, and <code class=\"\" data-line=\"\">DataSet<\/code>.<\/p>\n<hr data-start=\"5131\" data-end=\"5134\" \/>\n<h3 data-section-id=\"1d8p3xo\" data-start=\"5136\" data-end=\"5173\">19. What is a Repeater control?<\/h3>\n<p data-start=\"5175\" data-end=\"5332\"><strong data-start=\"5175\" data-end=\"5186\">Answer:<\/strong><br data-start=\"5186\" data-end=\"5189\" \/>A Repeater is a data-bound control that displays a repeated list of items based on the data source. It offers full control over HTML rendering.<\/p>\n<hr data-start=\"5334\" data-end=\"5337\" \/>\n<h3 data-section-id=\"1y3j4l1\" data-start=\"5339\" data-end=\"5376\">20. What is Cross Page Posting?<\/h3>\n<p data-start=\"5378\" data-end=\"5508\"><strong data-start=\"5378\" data-end=\"5389\">Answer:<\/strong><br data-start=\"5389\" data-end=\"5392\" \/>Cross Page Posting allows a form to be submitted to another page instead of itself using the <code class=\"\" data-line=\"\">PostBackUrl<\/code> property.<\/p>\n<h2 data-start=\"5378\" data-end=\"5508\"><strong>More ASP.NET Interview Questions for Freshers<\/strong><\/h2>\n<h3 data-section-id=\"rc0oyt\" data-start=\"129\" data-end=\"186\">21.What is the use of the <code class=\"\" data-line=\"\">IsPostBack<\/code> property?<\/h3>\n<p data-start=\"187\" data-end=\"495\"><strong data-start=\"187\" data-end=\"200\">Keywords:<\/strong> asp.net interview questions and answers<br data-start=\"240\" data-end=\"243\" \/><strong data-start=\"243\" data-end=\"254\">Answer:<\/strong><br data-start=\"254\" data-end=\"257\" \/><code class=\"\" data-line=\"\">IsPostBack<\/code> is a Boolean property of the Page class that tells whether the page is being loaded for the first time (<code class=\"\" data-line=\"\">false<\/code>) or as a result of a postback (<code class=\"\" data-line=\"\">true<\/code>). It is commonly used to avoid re-initializing data during every page load.<\/p>\n<hr data-start=\"497\" data-end=\"500\" \/>\n<h3 data-section-id=\"1pzyi7z\" data-start=\"502\" data-end=\"556\">22.How do you validate user input in ASP.NET?<\/h3>\n<p data-start=\"557\" data-end=\"776\"><strong data-start=\"557\" data-end=\"570\">Keywords:<\/strong> asp net interview questions and answers for freshers<br data-start=\"623\" data-end=\"626\" \/><strong data-start=\"626\" data-end=\"637\">Answer:<\/strong><br data-start=\"637\" data-end=\"640\" \/>ASP.NET provides both client-side and server-side validation. Server-side is more secure. You can use built-in validation controls like:<\/p>\n<ul data-start=\"777\" data-end=\"892\">\n<li data-start=\"777\" data-end=\"803\">\n<p data-start=\"779\" data-end=\"803\">RequiredFieldValidator<\/p>\n<\/li>\n<li data-start=\"804\" data-end=\"822\">\n<p data-start=\"806\" data-end=\"822\">RangeValidator<\/p>\n<\/li>\n<li data-start=\"823\" data-end=\"843\">\n<p data-start=\"825\" data-end=\"843\">CompareValidator<\/p>\n<\/li>\n<li data-start=\"844\" data-end=\"874\">\n<p data-start=\"846\" data-end=\"874\">RegularExpressionValidator<\/p>\n<\/li>\n<li data-start=\"875\" data-end=\"892\">\n<p data-start=\"877\" data-end=\"892\">CustomValidator<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"894\" data-end=\"897\" \/>\n<h3 data-section-id=\"h8mvvo\" data-start=\"899\" data-end=\"951\">23.What are Validation Controls in ASP.NET?<\/h3>\n<p data-start=\"952\" data-end=\"1112\"><strong data-start=\"952\" data-end=\"963\">Answer:<\/strong><br data-start=\"963\" data-end=\"966\" \/>Validation controls are used to ensure that the user input meets specific criteria. They validate data before sending it to the server. Example:<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"\" data-line=\"\">&lt;span class=&quot;hljs-tag&quot;&gt;&lt;&lt;span class=&quot;hljs-name&quot;&gt;asp:RequiredFieldValidator&lt;\/span&gt;&lt;\/span&gt; &lt;span class=&quot;hljs-attr&quot;&gt;ControlToValidate&lt;\/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;txtName&quot;&lt;\/span&gt; &lt;span class=&quot;hljs-attr&quot;&gt;ErrorMessage&lt;\/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;Name required&quot;&lt;\/span&gt; &lt;span class=&quot;hljs-attr&quot;&gt;runat&lt;\/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;server&quot;&lt;\/span&gt; \/&gt;<br \/>\n<\/code><\/div>\n<\/div>\n<hr data-start=\"1229\" data-end=\"1232\" \/>\n<h3 data-section-id=\"yq4vnq\" data-start=\"1234\" data-end=\"1284\">24.xplain Role-Based Security in ASP.NET<\/h3>\n<p data-start=\"1285\" data-end=\"1521\"><strong data-start=\"1285\" data-end=\"1296\">Answer:<\/strong><br data-start=\"1296\" data-end=\"1299\" \/>Role-based security allows you to manage access by assigning users to roles like &#8220;Admin&#8221;, &#8220;Editor&#8221;, etc. You can restrict page or resource access using <code class=\"\" data-line=\"\">&lt;authorization&gt;<\/code> in <code class=\"\" data-line=\"\">web.config<\/code> or via the <code class=\"\" data-line=\"\">User.IsInRole()<\/code> method.<\/p>\n<hr data-start=\"1523\" data-end=\"1526\" \/>\n<h3 data-section-id=\"r46y75\" data-start=\"1528\" data-end=\"1605\">25.What is the difference between ExecuteScalar and ExecuteNonQuery?<\/h3>\n<p data-start=\"1606\" data-end=\"1619\"><strong data-start=\"1606\" data-end=\"1617\">Answer:<\/strong><\/p>\n<ul data-start=\"1620\" data-end=\"1818\">\n<li data-start=\"1620\" data-end=\"1709\">\n<p data-start=\"1622\" data-end=\"1709\"><code class=\"\" data-line=\"\">ExecuteScalar()<\/code> returns a single value from the database (e.g., <code class=\"\" data-line=\"\">SELECT COUNT(*)<\/code>).<\/p>\n<\/li>\n<li data-start=\"1710\" data-end=\"1818\">\n<p data-start=\"1712\" data-end=\"1818\"><code class=\"\" data-line=\"\">ExecuteNonQuery()<\/code> executes commands like INSERT, UPDATE, DELETE and returns the number of rows affected.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"1820\" data-end=\"1823\" \/>\n<h3 data-section-id=\"lts993\" data-start=\"1825\" data-end=\"1888\">26.What are the different types of cookies in ASP.NET?<\/h3>\n<p data-start=\"1889\" data-end=\"1902\"><strong data-start=\"1889\" data-end=\"1900\">Answer:<\/strong><\/p>\n<ul data-start=\"1903\" data-end=\"2086\">\n<li data-start=\"1903\" data-end=\"1989\">\n<p data-start=\"1905\" data-end=\"1989\"><strong data-start=\"1905\" data-end=\"1927\">Persistent Cookies<\/strong>: Stored on the client\u2019s hard drive with an expiration date.<\/p>\n<\/li>\n<li data-start=\"1990\" data-end=\"2086\">\n<p data-start=\"1992\" data-end=\"2086\"><strong data-start=\"1992\" data-end=\"2028\">Non-persistent (Session) Cookies<\/strong>: Stored in memory and removed when the browser is closed.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"2088\" data-end=\"2091\" \/>\n<h3 data-section-id=\"2eabx6\" data-start=\"2093\" data-end=\"2142\">27.What are Themes and Skins in ASP.NET?<\/h3>\n<p data-start=\"2143\" data-end=\"2273\"><strong data-start=\"2143\" data-end=\"2156\">Keywords:<\/strong> asp net interview questions for freshers<br data-start=\"2197\" data-end=\"2200\" \/><strong data-start=\"2200\" data-end=\"2211\">Answer:<\/strong><br data-start=\"2211\" data-end=\"2214\" \/>Themes are used to apply a consistent style across pages.<\/p>\n<ul data-start=\"2274\" data-end=\"2440\">\n<li data-start=\"2274\" data-end=\"2316\">\n<p data-start=\"2276\" data-end=\"2316\"><strong data-start=\"2276\" data-end=\"2286\">Themes<\/strong>: Define overall appearance.<\/p>\n<\/li>\n<li data-start=\"2317\" data-end=\"2440\">\n<p data-start=\"2319\" data-end=\"2440\"><strong data-start=\"2319\" data-end=\"2328\">Skins<\/strong>: Define style properties for individual controls.<br data-start=\"2378\" data-end=\"2381\" \/>They are defined in <code class=\"\" data-line=\"\">.skin<\/code> files in the App_Themes folder.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"2442\" data-end=\"2445\" \/>\n<h3 data-section-id=\"1iiueoq\" data-start=\"2447\" data-end=\"2509\">28.What is the use of the <code class=\"\" data-line=\"\">Runat=&quot;server&quot;<\/code> attribute?<\/h3>\n<p data-start=\"2510\" data-end=\"2688\"><strong data-start=\"2510\" data-end=\"2521\">Answer:<\/strong><br data-start=\"2521\" data-end=\"2524\" \/>This attribute makes HTML elements accessible on the server side. It converts the control into a server control, allowing it to be manipulated through C# or VB.NET.<\/p>\n<hr data-start=\"2690\" data-end=\"2693\" \/>\n<h3 data-section-id=\"1aq1t81\" data-start=\"2695\" data-end=\"2770\">29.What are the different types of navigation controls in ASP.NET?<\/h3>\n<p data-start=\"2771\" data-end=\"2784\"><strong data-start=\"2771\" data-end=\"2782\">Answer:<\/strong><\/p>\n<ul data-start=\"2785\" data-end=\"2939\">\n<li data-start=\"2785\" data-end=\"2828\">\n<p data-start=\"2787\" data-end=\"2828\"><strong data-start=\"2787\" data-end=\"2795\">Menu<\/strong>: Displays a hierarchical menu.<\/p>\n<\/li>\n<li data-start=\"2829\" data-end=\"2885\">\n<p data-start=\"2831\" data-end=\"2885\"><strong data-start=\"2831\" data-end=\"2843\">TreeView<\/strong>: Displays hierarchical data with nodes.<\/p>\n<\/li>\n<li data-start=\"2886\" data-end=\"2939\">\n<p data-start=\"2888\" data-end=\"2939\"><strong data-start=\"2888\" data-end=\"2903\">SiteMapPath<\/strong>: Shows breadcrumb-style navigation.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"2941\" data-end=\"2944\" \/>\n<h3 data-section-id=\"qfzidr\" data-start=\"2946\" data-end=\"2989\">30.How does ASP.NET manage memory?<\/h3>\n<p data-start=\"2990\" data-end=\"3157\"><strong data-start=\"2990\" data-end=\"3001\">Answer:<\/strong><br data-start=\"3001\" data-end=\"3004\" \/>ASP.NET uses the CLR&#8217;s garbage collection feature to manage memory. Objects that are no longer in use are automatically reclaimed, reducing memory leaks.<\/p>\n<hr data-start=\"3159\" data-end=\"3162\" \/>\n<h3 data-section-id=\"1md4b08\" data-start=\"3164\" data-end=\"3209\">31.What is a Web Service in ASP.NET?<\/h3>\n<p data-start=\"3210\" data-end=\"3411\"><strong data-start=\"3210\" data-end=\"3221\">Answer:<\/strong><br data-start=\"3221\" data-end=\"3224\" \/>A web service allows communication between applications over the web using XML, SOAP, and HTTP. It enables platform-independent interaction and is declared using <code class=\"\" data-line=\"\">[WebService]<\/code> attribute.<\/p>\n<hr data-start=\"3413\" data-end=\"3416\" \/>\n<h3 data-section-id=\"1lrfjdw\" data-start=\"3418\" data-end=\"3477\">32.What is WCF (Windows Communication Foundation)?<\/h3>\n<p data-start=\"3478\" data-end=\"3660\"><strong data-start=\"3478\" data-end=\"3489\">Answer:<\/strong><br data-start=\"3489\" data-end=\"3492\" \/>WCF is a Microsoft framework for building service-oriented applications. It supports various communication protocols and is more flexible than traditional web services.<\/p>\n<hr data-start=\"3662\" data-end=\"3665\" \/>\n<h3 data-section-id=\"16mf7fj\" data-start=\"3667\" data-end=\"3723\">33.How do you connect to a database in ASP.NET?<\/h3>\n<p data-start=\"3724\" data-end=\"3831\"><strong data-start=\"3724\" data-end=\"3735\">Answer:<\/strong><br data-start=\"3735\" data-end=\"3738\" \/>Use ADO.NET with classes like <code class=\"\" data-line=\"\">SqlConnection<\/code>, <code class=\"\" data-line=\"\">SqlCommand<\/code>, and <code class=\"\" data-line=\"\">SqlDataAdapter<\/code>. Example:<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"\" data-line=\"\">SqlConnection conn = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;\/span&gt; SqlConnection(&lt;span class=&quot;hljs-string&quot;&gt;&quot;Your_Connection_String&quot;&lt;\/span&gt;);<br \/>\nconn.Open();<br \/>\n<\/code><\/div>\n<\/div>\n<hr data-start=\"3926\" data-end=\"3929\" \/>\n<h3 data-section-id=\"1l7luqk\" data-start=\"3931\" data-end=\"3991\">34.What is SQL Injection and how do you prevent it?<\/h3>\n<p data-start=\"3992\" data-end=\"4162\"><strong data-start=\"3992\" data-end=\"4003\">Answer:<\/strong><br data-start=\"4003\" data-end=\"4006\" \/>SQL Injection is an attack where malicious SQL is inserted into an input field.<br data-start=\"4085\" data-end=\"4088\" \/><strong data-start=\"4088\" data-end=\"4103\">Prevention:<\/strong> Use parameterized queries or stored procedures.<br data-start=\"4151\" data-end=\"4154\" \/>Example:<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"\" data-line=\"\">cmd.CommandText = &lt;span class=&quot;hljs-string&quot;&gt;&quot;SELECT * FROM Users WHERE Username = @username&quot;&lt;\/span&gt;;<br \/>\ncmd.Parameters.AddWithValue(&lt;span class=&quot;hljs-string&quot;&gt;&quot;@username&quot;&lt;\/span&gt;, userInput);<br \/>\n<\/code><\/div>\n<\/div>\n<hr data-start=\"4299\" data-end=\"4302\" \/>\n<h3 data-section-id=\"1nuccd7\" data-start=\"4304\" data-end=\"4345\">35.What is ViewBag and ViewData?<\/h3>\n<p data-start=\"4346\" data-end=\"4428\"><strong data-start=\"4346\" data-end=\"4357\">Answer:<\/strong><br data-start=\"4357\" data-end=\"4360\" \/>Both are used to pass data from controller to view in ASP.NET MVC.<\/p>\n<ul data-start=\"4429\" data-end=\"4520\">\n<li data-start=\"4429\" data-end=\"4467\">\n<p data-start=\"4431\" data-end=\"4467\"><code class=\"\" data-line=\"\">ViewData<\/code> is a dictionary object.<\/p>\n<\/li>\n<li data-start=\"4468\" data-end=\"4520\">\n<p data-start=\"4470\" data-end=\"4520\"><code class=\"\" data-line=\"\">ViewBag<\/code> is a dynamic property and easier to use.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"4522\" data-end=\"4525\" \/>\n<h3 data-section-id=\"5p206u\" data-start=\"4527\" data-end=\"4575\">36. What is Razor Syntax in ASP.NET MVC?<\/h3>\n<p data-start=\"4576\" data-end=\"4687\"><strong data-start=\"4576\" data-end=\"4587\">Answer:<\/strong><br data-start=\"4587\" data-end=\"4590\" \/>Razor is a markup syntax used in ASP.NET MVC views to embed server code within HTML.<\/p>\n<hr data-start=\"4730\" data-end=\"4733\" \/>\n<h3 data-section-id=\"jy45cr\" data-start=\"4735\" data-end=\"4783\">37. What is GAC (Global Assembly Cache)?<\/h3>\n<p data-start=\"4784\" data-end=\"4964\"><strong data-start=\"4784\" data-end=\"4795\">Answer:<\/strong><br data-start=\"4795\" data-end=\"4798\" \/>GAC stores .NET assemblies that are shared among multiple applications. It ensures versioning and security. Assemblies must be strongly named to be stored in the GAC.<\/p>\n<hr data-start=\"4966\" data-end=\"4969\" \/>\n<h3 data-section-id=\"1hr36l2\" data-start=\"4971\" data-end=\"5019\">38. What are async and await in ASP.NET?<\/h3>\n<p data-start=\"5020\" data-end=\"5138\"><strong data-start=\"5020\" data-end=\"5031\">Answer:<\/strong><br data-start=\"5031\" data-end=\"5034\" \/>These are keywords used for asynchronous programming. They help avoid blocking the main thread. Example:<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\"><code class=\"\" data-line=\"\">&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;public&lt;\/span&gt;&lt;\/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;\/span&gt; Task&lt;&lt;span class=&quot;hljs-built_in&quot;&gt;string&lt;\/span&gt;&gt; &lt;span class=&quot;hljs-title&quot;&gt;GetDataAsync&lt;\/span&gt;() {<br \/>\n&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;\/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;\/span&gt; httpClient.GetStringAsync(&lt;span class=&quot;hljs-string&quot;&gt;&quot;https:\/\/api.example.com\/data&quot;&lt;\/span&gt;);<br \/>\n}<br \/>\n<\/code><\/div>\n<\/div>\n<hr data-start=\"5275\" data-end=\"5278\" \/>\n<h3 data-section-id=\"bpki31\" data-start=\"5280\" data-end=\"5333\">39.How do you deploy an ASP.NET application?<\/h3>\n<p data-start=\"5334\" data-end=\"5369\"><strong data-start=\"5334\" data-end=\"5345\">Answer:<\/strong><br data-start=\"5345\" data-end=\"5348\" \/>You can deploy via:<\/p>\n<ul data-start=\"5370\" data-end=\"5552\">\n<li data-start=\"5370\" data-end=\"5399\">\n<p data-start=\"5372\" data-end=\"5399\">FTP to a hosting provider<\/p>\n<\/li>\n<li data-start=\"5400\" data-end=\"5433\">\n<p data-start=\"5402\" data-end=\"5433\">Publish through Visual Studio<\/p>\n<\/li>\n<li data-start=\"5434\" data-end=\"5552\">\n<p data-start=\"5436\" data-end=\"5552\">Azure deployment<br data-start=\"5452\" data-end=\"5455\" \/>Deployment includes copying files, configuring the web server (IIS), and setting up <code class=\"\" data-line=\"\">web.config<\/code>.<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"5554\" data-end=\"5557\" \/>\n<h3 data-section-id=\"trrom2\" data-start=\"5559\" data-end=\"5632\">40.How do you improve the performance of an ASP.NET application?<\/h3>\n<p data-start=\"5633\" data-end=\"5646\"><strong data-start=\"5633\" data-end=\"5644\">Answer:<\/strong><\/p>\n<ul data-start=\"5647\" data-end=\"5850\">\n<li data-start=\"5647\" data-end=\"5687\">\n<p data-start=\"5649\" data-end=\"5687\">Use caching (Output, Data, Fragment)<\/p>\n<\/li>\n<li data-start=\"5688\" data-end=\"5719\">\n<p data-start=\"5690\" data-end=\"5719\">Minimize server round-trips<\/p>\n<\/li>\n<li data-start=\"5720\" data-end=\"5749\">\n<p data-start=\"5722\" data-end=\"5749\">Optimize database queries<\/p>\n<\/li>\n<li data-start=\"5750\" data-end=\"5783\">\n<p data-start=\"5752\" data-end=\"5783\">Use bundling and minification<\/p>\n<\/li>\n<li data-start=\"5784\" data-end=\"5822\">\n<p data-start=\"5786\" data-end=\"5822\">Implement asynchronous programming<\/p>\n<\/li>\n<li data-start=\"5823\" data-end=\"5850\">\n<p data-start=\"5825\" data-end=\"5850\">Remove unused ViewState<\/p>\n<\/li>\n<\/ul>\n<h2 data-section-id=\"1t7n6pu\" data-start=\"147\" data-end=\"223\"><strong data-start=\"153\" data-end=\"223\">Conclusion on asp.net interview questions and answers for freshers<\/strong><\/h2>\n<p data-start=\"225\" data-end=\"547\">Mastering these <strong data-start=\"241\" data-end=\"284\">asp.net interview questions and answers<\/strong> is essential for any aspiring web developer stepping into the world of Microsoft technologies. Whether you&#8217;re preparing for your first technical round or building real-time projects, these <strong data-start=\"474\" data-end=\"518\">asp net interview questions for freshers<\/strong> provide a strong foundation.<\/p>\n<p data-start=\"549\" data-end=\"918\">To take your skills to the next level, consider enrolling in a <a href=\"https:\/\/www.kaashivinfotech.com\/dotnet-course\/\"><strong data-start=\"612\" data-end=\"637\">.NET Developer course<\/strong><\/a> that covers everything from the basics of C# and ASP.NET to advanced topics like Entity Framework, MVC, Web APIs, and deployment. A structured course not only boosts your practical knowledge but also increases your chances of clearing interviews and landing your first job faster.<\/p>\n<p data-start=\"1184\" data-end=\"1274\">Keep practicing, stay updated, and you\u2019ll soon find yourself thriving as a .NET developer!<\/p>\n","protected":false},"excerpt":{"rendered":"If you&#8217;re preparing for your first job in web development, this guide on asp.net interview questions and answers&hellip;","protected":false},"author":2,"featured_media":9514,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_singular_sidebar":"","csco_page_header_type":"","csco_page_load_nextpost":"","footnotes":""},"categories":[724],"tags":[804,806,808,802,799,800,809,801,803,811,805,810,807],"class_list":["post-2098","post","type-post","status-publish","format-standard","has-post-thumbnail","category-interview-questions","tag-net-interview-questions","tag-net-interview-questions-and-answers","tag-asp-dot-net-interview-questions","tag-asp-net-core-interview-questions","tag-asp-net-interview-questions","tag-asp-net-interview-questions-and-answers","tag-asp-net-mvc-interview-questions","tag-c-interview-questions","tag-c-interview-questions-and-answers","tag-c-interview-questions-with-answers","tag-dot-net-interview-questions","tag-mvc-core-interview-questions","tag-mvc-interview-questions","cs-entry"],"_links":{"self":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/2098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/comments?post=2098"}],"version-history":[{"count":78,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/2098\/revisions"}],"predecessor-version":[{"id":9518,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/posts\/2098\/revisions\/9518"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/media\/9514"}],"wp:attachment":[{"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/media?parent=2098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/categories?post=2098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kaashivinfotech.com\/blog\/wp-json\/wp\/v2\/tags?post=2098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}