Google

Monday, May 15, 2006

Answers upto question 13

Q - Explain the differences between Server-side and Client-side code?

 

Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.

 

Q - What type of code (server or client) is found in a Code-Behind Class?

 

Server side

 

Q - Should validation (did the user enter a real date) occur server-side or client-side? Why?

 

http://www.lhotka.net/WeBlog/CommentView,guid,8fa07593-a357-49a4-9b86-1ee82a58f2b9.aspx

 

Validation must be placed on server side, client side validations are welcome if placed. Lot of Web apps is that the validation is only put into the browser - which is horrible, because it is too easy to bypass. That is simply a flawed approach to development.

 

Another point is that UI technologies are changed too frequently (asp.net 2.0 is out and you never know when'd be next JavaScript version will be out!) but same is not the case with your business logic, that remains consistent for longer time.

 

At least with ASP.NET there are the validation controls, which simplify the process of creating and maintaining the duplicate validation logic in the browser. You are still left to manually keep the logic in sync, but at least it doesn't require hand-coding JavaScript in most cases.

 

Q - What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?

 

Response.Redirect simply sends a message down to the browser, telling it to move to another page. So, you may run code like:

 

Response.Redirect("WebForm2.aspx")

or

 

Response.Redirect("http://www.karlmoore.com/")

to send the user to another page.

 

Server.Transfer is similar in that it sends the user to another page with a statement such as Server.Transfer("WebForm2.aspx"). However, the statement has a number of distinct advantages and disadvantages.

 

Firstly, transferring to another page using Server.Transfer conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.

 

But watch out: because the "transfer" process can work on only those sites running on the server, you can't use Server.Transfer to send the user to an external site. Only Response.Redirect can do that.

 

Secondly, Server.Transfer maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.

 

That's not all: The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("WebForm2.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to.

 

For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you'd be able to retrieve the value of the original page TextBox control by referencing Request.Form("TextBox1").

 

This technique is great for wizard-style input forms split over multiple pages. But there's another thing you'll want to watch out for when using the preserveForm parameter. ASP.NET has a bug whereby, in certain situations, an error will occur when attempting to transfer the form and query string values. You'll find this documented at http://support.microsoft.com/default.aspx?id=kb;en-us;Q316920.

 

The unofficial solution is to set the enableViewStateMac property to True on the page you'll be transferring to, then set it back to False. This records that you want a definitive False value for this property and resolves the bug.

 

So, in brief: Response.Redirect simply tells the browser to visit another page. Server.Transfer helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables.

 

 

Q - Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component.

 

(http://www.oreilly.com/catalog/comdotnetsvs/chapter/ch10.html )

 

A .NET component that uses COM+ services is called a serviced component to distinguish it from the standard managed components in .NET.

 

One imp point which I get is web services are not restricted through firewalls and stuffs, since it uses text based protocols, but non serviced components can be stopped.

 

Another point (I dunno whether I m correct or not) web services can be device independent, i.e., same web service can be called from cell phone as well as your program.

 

Q Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

 

1. ASP.NET DataSet is Designed for connected access (through connection object).

2. Dataset is a data structure which represents the complete table data at same time.

3. Dataset is just a data store and manipulation is done through DataAdapters in .NET.

4. DataSet can contain multiple tables Retrieving data from more than one table or source does not require a JOIN.

5. XML, like HTML, is plaintext: "Firewall friendly"

 

About RecordSet:

 

1. ADO RecordSet is disconnected Architecture.

2. Recordset provides data one row at a time.

3. Recordset has the logic to update and manipulate data

4. The RecordSet is the central data container

RecordSet is one (1) table that contains all the data

Retrieving data from more than one table or source requires a database JOIN.

5. Problems marshalling through firewalls (DCOM, binary)

 

Q Can you give an example of what might be best suited to place in

the Application_Start and Session_Start subroutines?

 

We may initialize site visit counter variable in Application start.

In session start, we may initialize time spent by user variable

 

Q If I'm developing an application that must accomodate multiple security levels though secure login and my ASP.NET web appplication is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users?

 

OutProc or SqlServer mode, since given condition is web farm condition in which inProc mode of storing session doesn't work

 

Q - How does VB.NET/C# achieve polymorphism?

Polymorphism is one of the crucial features of OOP. It means  "one name, multiple forms". It is also called as Overloading which means the use of same thing for different purposes. Using Polymorphism we can create as many functions we want with one function name but with different argument list. The function performs different operations based on the argument list in the function call. The exact function to be invoked will be determined by checking the type and number of arguments in the function.

 

The following code demonstrates the implementation of Polymorphism.

 

Module Module1

 

Sub Main()

Dim two As New One()

WriteLine(two.add(10))

'calls the function with one argument

WriteLine(two.add(10, 20))

'calls the function with two arguments

WriteLine(two.add(10, 20, 30))

'calls the function with three arguments

Read()

End Sub

 

End Module

 

Public Class One

Public i, j, k As Integer

 

Public Function add(ByVal i As Integer) As Integer

'function with one argument

Return i

End Function

 

Public Function add(ByVal i As Integer, ByVal j As Integer) As Integer

'function with two arguments

Return i + j

End Function

 

Public Function add(ByVal i As Integer, ByVal j As Integer, ByVal k As Integer) As Integer

'function with three arguments

Return i + j + k

End Function

 

End Class 

 

(I hope it'd not be pain in you're a** to convert this tiny code in c#)

 

Q - Can you explain what inheritance is and an example of when you might use it?

Q - How would you implement inheritance using VB.NET/C#?

 

Defining inheritance should not be a big thing, visit http://www.codeproject.com/aspnet/AspNetInheritance.asp for a practical scenario where inheritance can be used.

 

In this article, author has tried to create a simple role management framework. A common page does all security check and load data according to user and that common page is inherited by all the pages in the app.


2 Comments:

Blogger Utsav said...

http://blogs.crsw.com/mark/articles/254.aspx?Pending=true

visit this link for answers of many questions

May 15, 2006  
Anonymous Anonymous said...

This site could provide some interview questions

May 23, 2006  

Post a Comment

<< Home