Asp.net Interview questions and answers

                       Asp.net Interview questions and answers



  • 1.  Does Main() always have to be public?
       -->    No.
  • 2.How do you turn off SessionState in the web.config file?
       -->  just simply put following code to disable SessionState.

             <httpModules>

             <remove name=”Session” />

             </httpModules>
  • 3. short-circuited operators: 
           -->  short-circuited operators

In C#, "&" and "|" operators evaluate both boolean expressions in the statement.
However, the "&&" operator only evaluates the first Boolean if false ,and the "||" operator only evaluates the first Boolean if true.
This technique prevents the execution of the second expression if unnecessary.
So,To achieve performance in your application.

//Don't use this:
if (_username ==”” & _password == “”)
{
}
//Make a practice of this in your whole application:
if (_username == “” && _password == “”)
{
}


  • 4. Use of TempData, (ViewData , ViewBag), Hiddenfield and query string.
  --->   TempData are used when we want to pass session variable or data from 
           controller to controller.
 --->  ViewData & ViewBag are used when  want to pass data from controller to                  view.
 --->  Hidden fields , query string are used when  want to pass data from view to                controller.

         C------->C  = TempData
         C------->V  = ViewData,ViewBag
         V------->C  = HiddenFields,query strings 


Comments

Popular posts from this blog

On-premises Data Visualization on Power BI

Top 50 Interview questions for intermediate MVC and .net developer