ASP.NET : 3+ Years of Expreience Interview Questions and Answers

1.)View state how u make that so that view state in page can not be tampered?

Administrator wants to make a security check that no one has tampered with ViewState, how can we ensure this? Microsoft has provided two mechanisms for increasing the security of ViewState. Machine Authentication Check (MAC) - tamper-proofing <%@ Page EnableViewStateMac="true"%> Encrypting the ViewState This encryption can only be applied at the machine.config level, as follows:

2.) Types of Session state mode?

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. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm. SQLServer mode stores session state in a SQL Server database. This ensures that session state is reserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm. Custom mode, which enables you to specify a custom storage provider. Off mode, which disables session state.

3.) In which database sql server session will be stored?

Session state is stored in the tempdb database of SQL Server.

4) How to call javascript function from webform1 to webform2?

Using Submit Form Method : You can submit the form in Webform1.aspx to webform2.aspx. In that case, you can retrieve all the WebForm1's form element from webform2. What we will do in the below example is to add another form ( not a server side one) which will have two HTML controls; the first is an submit control the second is a hidden field which will have the value of TextBox1 web server control to be posted to webform2 Ex: now the HTML code of webform1 will look like below
< form id="Form1" method="post" runat="server">< /form>
< asp:textbox id="TextBox1" runat="server" >< /asp:textbox>
< form action="WebForm2.aspx" method="post" name="SubmittedForm"> < /form>
< input id="Submit1" onclick="CopyTextToHiddenField()" value="submit"/>
< input name="Hidden1" />
Of course you realized the we handled the onclick event of the submit button which will call a javascript function to copy the value of TextBox1 into the hidden field (Hidden1) in order to post it to webform2. Also you so in the second form tag the action attribute in which we specified to which page the second form (SubmittedForm) will be posted.Add the below javascript code inside the tag of WebForm1.

< script language="javascript" >
function CopyTextToHiddenField()
{
var textbox1Value = document.getElementById
("<%=TextBox1.ClientID%>").value;
document.forms[1].document.getElementById
("Hidden1").value = textbox1Value;
}
< /script>
Now you retrieve the value of "Hidden1" hidden field in webform 2 using the below code Response.Write(Request.Form["Hidden1"]);

5) Webserver controls and Html controls differences?

U can get more difference here Difference Between Web Server Control and HTML Controls

6.) Difference between temporary table and derived table?

Using temp table you can able insert the value only at runtime. derived table you can insert the data anytime and view also anytime. Explicit Indexing and Constraints are allowed in temp tables. Explicit Indexing and Constraints are not Applicable In Derived tables.

7.) How to call javascript from c# code under button_click without using Button1.Attributes.Is there any method?

string strsql = "< script language="javascript" >
lovechild=window.open('Default.aspx','',
'width:150px, resizable=no,scroolbar=no');
"; this.Response.Write(strsql);

8.)which session state mode you used in your current project?why?

it depends on your project . by default InProc mode.

9.) Diffrences between UDF and Stored procedures?

  • Procedure can return zero or n values whereas function can return one value which is mandatory.
  • Procedures can have input,output parameters for it whereas functions can have only input parameters.
  • Procedure allow select as well as DML statement in it whereas function allow only select statement in it.
  • Functions can be called from procedure whereas procedures cannot be called from function.
  • Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
  • We can go for transaction management in procedure whereas we can't go in function.
  • Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.

10.) CCW,RCW why to use com components when we can manage everything with dlls?

We can't manage Everthing with dlls .becz few problems will face when handling with dlls Forex: DLL hell and etc. so, A .NET component, however, is a pre-compiled class module with a .DLL (dynamically-linked library) extension. At run time, a .NET component is invoked and loaded into memory to be used by some consumer application. You may have a single DLL that supports error handling in your applications. In this case, the DLL exposes a single ErrorHandler class that performs all of the error handling required by consumer applications. So,.Net Components can't communicate with Com directly,so we can do using RCW (Runtime callable Wrapper) and CCW .