All java c# asp.net .net servlet jdbc c sqlserver android ado.net javascript php wcf clearcase angularjs 2

What are the types of cookies?

Cookies can be broadly classified into 2 types

1. Persistent cookies: Remain on the client computer, even after the browser is closed. You can configure how long the cookies remain using the expires property of the Http Cookie object.

2. Non-Persistent cookies: If you don't set the Expires property, then the cookie is called as a Non-Persistent cookie. Non-Persistent cookies only remain in memory until the browser is closed.

There two type of cookies ..
 Persistent cookies: cookies are stored on your computer hard disk. They stay on your hard disk and can be accessed by web servers until they are deleted or have expired. 
public void SetPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;
 cookie.Expires = Convert.ToDateTime(“12/12/2008”);
 Response.Cookies.Add(cookie);}

Non-persistent cookies: cookies are saved only while your web browser is running. They can be used by a web server only until you close your browser. They are not saved on your disk.
 public void SetNonPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;
 Response.Cookies.Add(cookie);}

What is a NullPointer Exception in asp.net and how to fix it

Null pointer exception means you are trying to access a member field or a function from an object which is null. for example you created a object of a class object name is "ClassAobj" and you want a variable value from class which is assign and initilize in that class now int a = ClassAobj.Number1; if "ClassAobj" is null then you can not access the value of Number1 . for fixing it ,either you have to initilize the class or you have to full if condition if(ClassAobj != null) { int a = ClassAobj.Number1; }

You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all.

Like anything else, null gets passed around. If it is null in method "A", it could be that method "B" passed a null to method "A".

The rest of this article goes into more detail and shows mistakes that many programmers often make which can lead to a NullReferenceException.

How do you create a Persistent Cookie?

You create a persistent cookie the same way as session cookies except that you set the Expires property to a Date in the future which will store the Cookie to the client computer hard drive.

//Code to create a UserName Persistent Cookie that lives for 10 days
HttpCookie CookieObject = new HttpCookie("UserName", "David");
CookieObject.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(CookieObject);

//Code to read the Cookie created above
Request.Cookies["UserName"].Value;

Cookies have an expiration date implicitly or explicitly set which controls how long they last (subject to the user agent actually enforcing it). A cookie may persist only for the duration of the session (or an even shorter period).

If a cookie is valid, it will be passed along with the HTTP request to the domain that it originated from. Only the domain that set the cookie can read the cookie (though there are ways to exploit this, such as cross-site scripting).

  • If you want a cookie to expire at a specific time, set an expiration date on it using the client or server-side language of your choice.

  • If you want the cookie to expire when the session ends, don't set an expiration date.

What is static polymorphism and dynamic polymorphism?

STATIC POLYMORPHISM:

A method which will bind at compile time will execute in runtime is called as static polymorphism or early binding or compile time polymorphism

DYNAMIC POLYMORPHISM:

A method which will bind at compile time will not execute, instead of that a method which will bind at runtime will execute is called as RUNTIME

POLYMORPHISM (or) DYNAMIC POLYMORPHISM is nothing but LATE BINDING.

Static polymorphism:

The process of binding the overloaded method within object at compile time is known as Static polymorphism due to static polymorphism utilization of resources (main memory space) is poor because for each and every overloaded method a memory space is created at compile time when it binds with an object. In C++ environment the above problem can be solve by using dynamic polymorphism by implementing with virtual and pure virtual function so most of the C++ developer in real worlds follows only dynamic polymorphism.

Dynamic polymorphism:

In dynamic polymorphism method of the program binds with an object at runtime the advantage of dynamic polymorphism is allocating the memory space for the method (either for overloaded method or for override method) at run time.

Polymorphism means one name, multiple forms. It allows us to have more than one function with the same name in a program.It allows us to have overloading of operators so that an operation can exhibit different behaviours in different instances.

What is the difference between Session Cookies and Persistent Cookies?

Persistent Cookies are same as Session Cookies except that, persistent cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client's hard drive. Keep in mind that because a user can delete cookies from their machine that there is no guarantee that a cookie you "drop" on a user machine will be there the next time they visit your site.

Session cookies - these are temporary cookie files, which are erased when you close your browser. When you restart your browser and go back to the site that created the cookie, the website will not recognize you. You will have to log back in (if login is required) or select your preferences/themes again if the site uses these features. A new session cookie will be generated, which will store your browsing information and will be active until you leave the site and close your browser. More on session cookies.

Persistent cookies – these files stay in one of your browser's subfolders until you delete them manually or your browser deletes them based on the duration period contained within the persistent cookie's file

Session cookies are stored in memory and never written to disk. When the browers closes the cookie is permanently lost from this point on. If the cookie contains an expiration date, it is considered a persistent cookie. On the date specified in the expiration, the cookie will be removed from the disk.

What is the data provider to communicate sql server data base?

Every DataProvider is providing by the Microsoft as a Base class library (BCL). To communicate Sql server database we have to import a BCL called Using System.Data.SqlClient;

.NET Framework Data Provider for OLE DB

DriverProvider
SQLOLEDBMicrosoft OLE DB provider for SQL Server
MSDAORAMicrosoft OLE DB provider for Oracle
Microsoft.Jet.OLEDB.4.0OLE DB provider for Microsoft Jet

The following table lists the data providers that are included in the .NET Framework.

.NET Framework data provider

Description

.NET Framework Data Provider for SQL Server

Provides data access for Microsoft SQL Server. Uses the System.Data.SqlClient namespace.

.NET Framework Data Provider for OLE DB

For data sources exposed by using OLE DB. Uses the System.Data.OleDb namespace.

.NET Framework Data Provider for ODBC

For data sources exposed by using ODBC. Uses the System.Data.Odbc namespace.

.NET Framework Data Provider for Oracle

For Oracle data sources. The .NET Framework Data Provider for Oracle supports Oracle client software version 8.1.7 and later, and uses the System.Data.OracleClient namespace.

EntityClient Provider

Provides data access for Entity Data Model (EDM) applications. Uses the System.Data.EntityClient namespace.

.NET Framework Data Provider for SQL Server Compact 4.0.

Provides data access for Microsoft SQL Server Compact 4.0. Uses the System.Data.SqlServerCe namespace.

Can we run asp.net application without IIS?

Yes. Using ASP.NET DEVELOPMENT SERVER which is the default server in ASP.NET.

It is easy to run your asp.net web application without installing any web server. For running your application without IIS you have to use Cassini Desktop Adapter.

Features of Cassini Desktop Adapter

* Standalone Web Applications – now on the Desktop
* 100% Embedded Web server
* No Installation or GAC Required
* No Administrator Privileges Required
* No XML / Configuration Files
* Cassini On-Demand

Download Link
Download Cassini

After Extracting above zip file you will find a folder named “Standalone.Simple”
It has following sub directory
\Cassini
\WebApp
\Standalone.Simple.bat

Now do following steps
-> Just put your web application on \webApp folder
-> Copy UltiDevCassiniHttpRequestProcessor2.0.dll from \Cassini folder
-> Now past it your bin folder
-> Now run Standalone.Simple.bat file (It will create virtual web server)

Now your application is running without IIS It also support VWG application.

How should a C# Web API model binder provider work?

If the parameter is a “simple” type, Web API tries to get the value from the URI. Simple types include the .NET Primitive Types (int, bool, double, and so forth), plus TimeSpan, DateTime, Guid, decimal, and string, plus any type with a type converter that can convert from a string. (More about type converters later.). For complex types, Web API tries to read the value from the message body, using a media type formatter.

For example, here is a typical Web API controller method:

public class MyModelBinderProvider: ModelBinderProvider
{
    public override IModelBinder GetBinder(HttpConfiguration configuration, Type modelType)
    {
        IModelBinder modelBinder = null;

        if (modelType.IsGenericType && (modelType.GetGenericTypeDefinition() == typeof(List<>)))
        {
            modelBinder = new ListModelBinder();   
        }
        return modelBinder;
    }
}
GlobalConfiguration.Configuration.Services.Insert(typeof(ModelBinderProvider), 0, new MyModelBinderProvider());
in Global.asax 

When Web API calls a method on a controller, it must set values for the parameters, a process called binding. This article describes how Web API binds parameters, and how you can customize the binding process.

By default, Web API uses the following rules to bind parameters:

  • If the parameter is a “simple” type, Web API tries to get the value from the URI. Simple types include the .NET primitive types (intbooldouble, and so forth), plus TimeSpanDateTimeGuiddecimal, and stringplus any type with a type converter that can convert from a string. (More about type converters later.)
  • For complex types, Web API tries to read the value from the message body, using a media-type formatter.

How do you validate the controls in an ASP .NET page?

Using special validation controls that are meant for this. We have Range Validator, Email Validator

ASP.NET provides a set of validation controls that provide an easy-to-use but powerful way to check for errors and, if necessary, display messages to the user.They provide 6 types of validation controls

  1. RequiredFieldValidation Control
  2. CompareValidator Control
  3. RangeValidator Control
  4. RegularExpressionValidator Control
  5. CustomValidator Control
  6. ValidationSummary

What is difference b/w WCF and ASP.NET Web API

WCF-It is the evolution of the web service(ASMX) and support various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.

Web API- This is the new framework for building HTTP services with easy and simple way.Web API is open source an ideal platform for building REST-ful services over the .NET Framework.

It support MVC also

WCF It is also based on SOAP and return data in XML form.
It is the evolution of the web service(ASMX) and support various protocols like TCP, HTTP, HTTPS, Named Pipes, MSMQ.
The main issue with WCF is, its tedious and extensive configuration.
It is not open source but can be consumed by any client that understands xml.
It can be hosted with in the applicaion or on IIS or using window service.

WCF Rest To use WCF as WCF Rest service you have to enable webHttpBindings.
It support HTTP GET and POST verbs by [WebGet] and [WebInvoke] attributes respectively.
To enable other HTTP verbs you have to do some configuration in IIS to accept request of that particular verb on .svc files
Passing data through parameters using a WebGet needs configuration. The UriTemplate must be specified
It support XML, JSON and ATOM data format.

Web API This is the new framework for building HTTP services with easy and simple way. Web API is open source an ideal platform for building REST-ful services over the .NET Framework.
Unlike WCF Rest service, it use the full featues of HTTP (like URIs, request/response headers, caching, versioning, various content formats)
It also supports the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection, unit testing that makes it more simple and robust.
It can be hosted with in the application or on IIS.
It is light weight architecture and good for devices which have limited bandwidth like smart phones.
Responses are formatted by Web API’s MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.