public void UseDNS(){ string hostName = Dns.GetHostName(); Console.WriteLine("Host Name = " + hostName); IPHostEntry local = Dns.GetHostByName(hostName); foreach(IPAddress ipaddress in local.AddressList) { Console.WriteLine("IPAddress = " + ipaddress.ToString()); }}
Server Side Code Server side is the code that resides at web server. For every client request code is executed at server side and result is send to the client in simple HTML format. Performance is lower than client side code due to server round trips. Client cannot see the business logic though it is stored on server. Client Side Code Client side code is reside at client's browser itself. It is executed at client side only. User can easily see the code by View - > Source option. It is generally used in validation form like text field is empty or not, email address validation etc. It is faster than server side code.
What type of code (server or client) is found in a Code-Behind class?
As .NET is featured with Event Driven Programming code behind pages are used to separate the
even-procedures from content of page. So it containts Server Side code.
What is the difference between Servers? Transfer and Response. Redirect?
Server.Transfer() is used to transfer data between two different pages on the same server and the performance is fast than response.redirect. Response.redirect is used to transfer the control to another page residing at another server.
Can you give an example of what might be best suited to place in the Application Start and Session Start subroutines?
Application Start - We can place code to initialize variables once during application start. (e.g, db connection string) Session Start - We can place code to initialize variables specific to the session (e.g, USER ID and other specific info related to this session)
Application Start This Event is fired when the server which holding application starts whereas Session Start event is fired when any User has access that page or Session has been created. Suppose we want to track that how many users have accessed our sites today then Application Start is the best place to do so or we want to give some personalised view to User than Session is the best place.
Describe the difference between inline and code bebind model? which one is the best for losely coupled environment?
In .NET 2.0, with the introduction of partial class, there is no difference in inline coding & code behind as per performance. But in .NET1.1 the code behind file needed to be updated for any modifications. Moreover, in the inline coding model there was no intelligense support
How would you implement inheritance using VB.NET/C#?
When we set out to implement a class using inheritance, we must first start with an existing class from which we will derive our new subclass. This existing class, or base class, may be part of the .NET system class library framework, it may be part of some other application or .NET assembly, or we may create it as part of our existing application. Once we have a base class, we can then implement one or more subclasses based on that base class. Each of our subclasses will automatically have all of the methods, properties, and events of that base class ? including the implementation behind each method, property, and event. Our subclass can add new methods, properties, and events of its own - extending the original interface with new functionality. Additionally, a subclass can replace the methods and properties of the base class with its own new implementation - effectively overriding the original behavior and replacing it with new behaviors. Essentially inheritance is a way of merging functionality from an existing class into our new subclass. Inheritance also defines rules for how these methods, properties, and events can be merged.
Explain what a diffgram is, and a good use for one?
A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order.
Describe session handling in a webfarm, how does it work and what are the limits?
Sessions can be managed by two ways in case of webfarms: 1. Using SQL server or any other database for storing sessions regarding current logged in user. 2. Using State Server, as one dedicated server for managing sessions. State Server will run as service on web server having dotnet installed.
How would you get ASP.NET running in Apache web servers - why would you even do this?
Using mod_aspnet module from apache CLI project. Some organisations don't use IIS as web server as their policy.
In what order do the events of an ASPX page execute. As a developer is it important to understand that?
if you try to access it in Page_Load that is way earlier than Control's own Render method. See ther Page/control lifecycle goes like this for the Page and controls (being already in the controls collection, dynamic ones play catchup) 1. Instantiate 2. Initialize 3. TrackViewState 4. LoadViewState (postback) 5. Load postback data (postback, IPostBackDatahandler.LoadPostdata) 6. Load 7. Load postback data for dynamical controls added on Page_Load (postback) 8. Raise Changed Events (postback, IPostBackDatahandler.RaisePostDataChanged) 9. Raise postback event (postback, IPostBackEventHandler.RaisePostBackEvent) 10.PreRender 11. SaveViewState 12. Render 13. Unload 14. Dispose null
Can you edit data in the Repeater control?
No. We can not edit the data. Only format can be edited.
What base class do all Web inherit from?
System.Web.UI.Page
The Abandon method destroys all the objects stored in a Session object and releases their resources.If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.Syntax: Session.Abandon
How do you turn off cookies for one page in your site?
Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, thisproperty instructs the client application not to save the Cookie on the user’s hard disk when a session ends.
You can't turn off cookies in a single page
to turn off the cookies in an application
FireFox Tools-Options-deselect cookie, if selected.
Which two properties are on every validation control expect validation summary control?
ControlToValidate,Display,EnableClientScript,IsValid,ForeColor,Text,ErrorMessag,Enabled
The two properties shared by all validation controls except for ValidationSummary control are
Type and EnableClientScript.
How do you create a permanent cookie?
seeting the Expires Property to date less than todays date
What is the standard you use to wrap up a call to a Web service?
HTTP with SOAP
What does WSDL stand for?
WSDL stands for Web Services Description Language. It is an XML representation of the web service interface.
There are two types of the operations specified in the WSDL file, as represented by the
Document oriented operations -- are the ones which contain XML documents as input and output
Result oriented operations -- are the ones which contain input parameters as the input message and result as the output message
the Pager object?
The Pager Object tackles all the capabalities of the paging process into any ASP.NET control.
Where on the Internet would you look for Web services?
UDDI.org - Universal Description, Discovery language.
To test a Web service you must create a windows application or web application?
Run the web service project. It displays the
How many classes can a single .NET DLL contain?
Unlimited
What are HTML controls, Web controls, and server controls?
HTML Control - By default, HTML elements on a Web Forms page are not available to the server; they are treated as opaque text that is passed through to the browser. However, by converting HTML elements to HTML server controls, you expose them as elements you can program in server-based code.Web Control - Serves as the base class that defines the methods, properties and events common to all controls in the System.Web.UI.WebControls namespace.
Briefly explain how the server control validation controls work.
A validation control works by evaluating the value of an input server control on the page to see whether it meets certain criteria. The input control to evaluate is specified through the validation control’s ControlToValidate attribute. You can programmatically cause a validation control to perform its evaluation by calling its Validate method, which sets the validation control’s IsValid property to true if validation succeeds and false if it fails. You can cause all of the validation controls on a page to validate their input controls by calling the Page.Validate method. The Page.IsValid property is set to true if validation succeeds for all validation controls within the page; otherwise, it's false. The Page.Validate method is automatically invoked when a button control whose CausesValidation property is set to true is clicked. CausesValidation is set to false by default for a reset or clear button. The button click event is suppressed if IsValid is false for any validation control on the page .
Briefly explain what user controls are and what server controls are and the differences between the two.
An ASP.NET control (sometimes called a server control) is a server-side component that is shipped with .NET Framework. A server control is a compiled DLL file and cannot be edited. It can, however, be manipulated through its public properties at design-time or runtime. It is possible to build a custom server control (sometimes called a custom control or composite control). (We will build these in part 2 of this article.) In contrast, a user control will consist of previously built server controls (called constituent controls when used within a user control). It has an interface that can be completely edited and changed. It can be manipulated at design-time and runtime via properties that you are responsible for creating. While there will be a multitude of controls for every possible function built by third-party vendors for ASP.NET, they will exist in the form of compiled server controls, as mentioned above. Custom server controls may be the .NET answer to ActiveX Web controls.
Briefly explain how server form post-back works (perhaps ask about view state as well).
Post Back: The process in which a Web page sends data back to the same page on the server. View State: ViewState is the mechanism ASP.NET uses to keep track of server control state values that don't otherwise post back as part of the HTTP form. ViewState Maintains the UI State of a Page ViewState is base64-encoded. It is not encrypted but it can be encrypted by setting EnableViewStatMAC="true" & setting the machineKey validation type to 3DES. If you want to NOT maintain the ViewState, include the directive < %@ Page EnableViewState="false" % > at the top of an .aspx page or add the attribute EnableViewState="false" to any control.
Global.asax?
The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level and session-level events raised by ASP.NET or by HTTP modules. The Global.asax file resides in the root directoryof an ASP.NET application. At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplication base class. ASP.NET is configured so that any direct URL request for the Global.asax file is automatically rejected; external users cannot download or view the code in it.
The Global.asax file is optional. You create it only if you want to handle application or session events
How would ASP and ASP.NET apps run at the same time on the same server??
Both ASP and ASP.net can be run at same server, becuase IIS has the capability to respond/serve both ASP and ASP.NET request.
Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component?
Webservice: Appropriate, when exposing the functionalitiss across differnt platforms(windows/Linux/Solaris..etc.,) or.NET to J2EE. .NET Componet: Appropriate, when exposing the functionalitis within propritory O/S(.Net-.Net, or Java-Java platform)
Communicating through a Firewall When building a distributed application with 100s/1000s of users spread over multiple locations, there is always the problem of communicating between client and server because of firewalls and proxy servers. Exposing your middle tier components as Web Services and invoking the directly from a Windows UI is a very valid option. • Application Integration When integrating applications written in various languages and running on disparate systems. Or even applications running on the same platform that have been written by separate vendors. • Business-to-Business Integration This is an enabler for B2B intergtation which allows one to expose vital business processes to authorized supplier and customers. An example would be exposing electronic ordering and invoicing, allowing customers to send you purchase orders and suppliers to send you invoices electronically. • Software Reuse This takes place at multiple levels. Code Reuse at the Source code level or binary componet-based resuse. The limiting factor here is that you can reuse the code but not the data behind it. Webservice overcome this limitation. A scenario could be when you are building an app that aggregates the functionality of serveral other Applicatons. Each of these functions could be performed by individual apps, but there is value in perhaps combining the the multiple apps to present a unifiend view in a Portal or Intranet. • When not to use Web Services: Single machine Applicatons When the apps are running on the same machine and need to communicate with each other use a native API. You also have the options of using component technologies such as COM or .NET Componets as there is very little overhead. • Homogeneous Applications on a LAN If you have Win32 or Winforms apps that want to communicate to their server counterpart. It is much more efficient to use DCOM in the case of Win32 apps and .NET Remoting in the case of .NET Apps
Can you give an example of what might be best suited to place in the application_Start and Session_Start subroutines??
Application_Start event should be used for initializing application-wide used variables and objects. For example if you want to find out number of connected users at any time you may initialize a variable user_count to 1 in Application_Start
Session_Start should be used to initialize session specific variables, for example user name (to be shown on each page after the user loggs in) and other user preferences.
April 30, 2007 02:06:59
#2
deeptilove12002
Member Since: December 2006 Contribution: 1
RE: Can you give an example of what might be best suit...
Application_Start:----generally placed in global.asax page...As the first user visits the start page of a Web application, this event is occurred...this event is used to initialize the objects and data tht a user want to make available to all current sessions of the visited web applications..Session_Start:----generally placed in global.asax page...For each user visiting the web application, it creartes a new instances of session variables used by the visitor.......
What is "Common Language Specification"?
CLS specify certain set of rules to which, each .net languages should follow to achieve the language interoperability.Let take an situation:if u have 2 public classes in C#, let say class a and class A. if you want to use this classes in your VB project.iTry to create an object of class a/A, u will get an compilor error message, since VB is not case-sensitive language. it doesn't have any differencce in a and A. Hence your c# code is not CLS complience code. which imply u can't have 2 classes of same name those differ only in cases for CLS complience code to achieve language interoperability.
What is a Web Service?
A web service is a component which runs on a server and supports clients to be connected using open protocols like HTTP and SMTP.
It uses SOAP for wrapping its objects to travel on the network.
It exposes itself via UDDI. Users can search for a web service using UDDI.
A web service is described using WSDL.
WebSevice is a reusable software component (ClassLibraries) which exposes the businesslogic in them, platform independent, technology independent, language on which it is created, can be transported on HTTP (which is stateless) and provides the xml (Universal Accepted language which can be passed through firewalls) by exposing thruough SOAP (Simple Object Access Protocol) messages between the Caller and the component..
What are the Types of Assemblies?
Private, Public/Shared, Satellite
What is a Strong Name?
A strong name is a way to ensure that a shared assembly's name does not conflict with another shared assembly.
A strong name contains assembly name, a public key and a private key.
For installing an assembly into GAC you need to give it a strong name. First generate a key pair using 'sn.exe' command line utility and write the key file name as AssemblyKeyFileAttribute in a code file of the assembly.
To create a key pair use the dotnet command line tool sn.exe
sn.exe -k mykey.snk
This filename is used as the attribute value for AssemblyKeyFileAttribute in one of the code files of assembly. It generates a strong named assembly which could be installed into the GAC.
What is an Intermediate language?
MSIL is the intermediate language which is platform independent. High level language compilers for .Net languages compile the high level code into IL which is not hardware specific.
The use of IL allows integration of code written in different .Net languages which can be linked into one assembly. All lang compilers would produce IL code which is independent of the high level languages used.
IL uses common type system to bring data types of all .Net languages to a common platform.
What is GAC?
The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.You should share assemblies by installing them into the global assembly cache only when you need to. Assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. The cache performs these integrity checks to ensure that an assembly has not been tampered with, for example, when a file has changed but the manifest does not reflect the change. Use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK or Use Windows Explorer to drag assemblies into the cache. To install a strong-named assembly into the global assembly cache At the command prompt, type the following command: gacutil –I
GAC stands for Global Assembly Cache. It is used for storing shared assemblies. It stores all versions of a particular assembly so that on updating an assembly the existing applications which use the earlier version do not break.
For storing an assembly into the GAC you need to sign the assembly with a strong name. For this purpose follow these steps:
Use sn.exe command line utility to generate a key pair
Add the key file name to the assembly as value for AssemblyKeyFileAttribute.
Build the assembly.
Use gacutil.exe -i
A computer installed with the common language runtime has a machine-wide code cache known as Global Assembly Cache. In the .NET Framework, the Global Assembly Cache acts as the central place for registering the assemblies. All the shared Asp.Net assemblies have a unique name and they are placed in GAC.
Ways to deploy an assembly in GAC
1.An installer that works with the Global Assembly Cache can be used.
2.Use a developer tool called the Global Assembly Cache tool which is available in the .NET Framework SDK. We can also drag assemblies into the Global Assembly Cache using the Windows Explorer.
GAC is generally located in "Assembly" directory in WinNT.
What is Reflection?
It extends the benefits of metadata by allowing developers to inspect and use it at runtime. For example, dynamically determine all the classes contained in a given assembly and invoke their methods.Reflection provides objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. You can then invoke the type's methods or access its fields and properties.Namespace: System.Reflection
Reflection is a namespace in .net which allows you to access metadata for loaded types and objects.
It also allows you to create new types and their objects at runtime.
Reflection is the mechanism of discovering class information at run time or it is an
technique for reading meta data at run time
What are Attributes??
Attributes are declarative tags in code that insert additional metadata into an assembly. There exist two types of attributes in the .NET Framework: Predefined attributes such as AssemblyVersion, which already exist and are accessed through the Runtime Classes; and custom attributes, which you write yourself by extending the System.Attribute class.
Attributes are part of metadata for a class.
Attributes are used to specify assembly information like key file name, or for specifying security related information. You can create new attributes for your specific needs or ideas.
webFarm Vs webGardens
A web farm is a multi-server scenario. So we may have a server in each state of US. If the load on one server is in excess then the other servers step in to bear the brunt. How they bear it is based on various models.1. RoundRobin. (All servers share load equally)2. NLB (economical)3. HLB (expensive but can scale up to 8192 servers)4. Hybrid (of 2 and 3).5. CLB (Component load balancer).A web garden is a multi-processor setup. i.e., a single server (not like the multi server above).How to implement webfarms in .Net:Go to web.config and Here for mode = you have 4 options.a) Say mode=inproc (non web farm but fast when you have very few customers).b) Say mode=StateServer (for webfarm)c) Say mode=SqlServer (for webfarm)Whether to use option b or c depends on situation. StateServer is faster but SqlServer is more reliable and used for mission critical applications.How to use webgardens in .Net:Go to web.config and webGarden="false"...>Change the false to true. You have one more attribute that is related to webgarden in the same tag called cpuMask.
There is two or more than two server in webfarm method, and we also have a router in this technique, which is basically is used to route the a particular incoming request .Where as in case of a webgarden we have a one server having more than one processor.There are two techniques to implements webgarden 1. witout webgarden 2. with webgarden
No comments:
Post a Comment