8.19.2012

ASP.Net Difference FAQs-11

1.Difference between XML Serialization and Binary Serialization
S.No
XML Serialization
Binary Serialization (SOAP)
1
No need of Serializable attribute on the class
Need Serializable attribute
2
Only public members are serialized
All members are serialized unless specified as NonSerializable
3
Class should have default public constructor and class itself should have public access.
No need of default constructor or public access
4
Namespace: System.XML.Serialization
Namespace: System.Runtime.Serialization.Formatteres.Binary (.Soap)
5
Outputfile is XML
Outputfile is Binary or XML for SOAP formatter
6
XMLSerializer need type of object to be serialized or deserialized
No need to specify type of object to be serialized or deserialized.
7
Support only IDesrializationCallback interface. No support for binary events.
Binaryformatter support binary events. Soap formatter supports only IDeserializationCallback interface
2.Difference between CurrentCulture and CurrentUICulture
S.No
CurrentCulture
CurrentUICulture
1
CurrentCulture property affects how the .NET Framework handles regional options (dates, currencies, sorting, formatting, etc.) for the current user.i.e., it provides cultural context for formatting and parsing (for ex. to parse dates or numbers) A date is often written like '10/30/2000' by Americans, but '30/10/2000' by Irish people, and 30.10.2000 by Germans etc.
CurrentUICulture property determines which satellite assembly is used when loading resources and reflects the UI language for the current user.i.e., it provides the cultural context for localization, i.e. translation of resources.


2
CurrentCulture does not support neutral cultures (i.e. "en", "fr" ...). It is always a specific culture (i.e. "en-GB", "de-AT", "pt-BR")
CurrentUICulture supports neutral cultures (i.e. "en", "fr" ...)
Example for CurrentCulture - To parse the date in asp.net:
using System.Threading;
using System.Globalization;
DateTime dt;
// this is a British English date format
string dateStr = "31/10/2001";

// parse it with British English culture
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
bool parseOk = DateTime.TryParse(dateStr, out dt);
// parseOk: true -- dt: {31/10/2001 00:00:00}

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
parseOk = DateTime.TryParse(dateStr, out dt);
// parseOk: false-- dt: {1/1/0001 12:00:00 AM}
...

Example for CurrentUICulture - To get the resources in asp.net:

using System.Threading;
using System.Globalization;
string culture = "en";
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
string hello = (string)HttpContext.GetGlobalResourceObject("myClassKey", "myResourceKey");

// and now French
string culture = "fr";
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
string hello = (string)HttpContext.GetGlobalResourceObject("myClassKey", "myResourceKey");
...

3.Difference between Forms Authentication and Windows Authentication
S.No
Forms Authentication
Windows Authentication
1
Forms authentication enables us to identify users with a custom database, such as an ASP.NET membership database. Alternatively, we can implement our own custom database. Once authenticated, we can reference the roles the user is in to restrict access to portions of our Web site.
Windows authentication enables us to identify users without creating a custom page. Credentials are stored in the Web servers local user database or an Active Directory domain. Once identified, we can use the users credentials to gain access to resources that are protected by Windows authorization.
2
Form authentication is preferable for the applications which have diversified users from several places.
Windows authentication is best suited for the application which is meant for a corporate users
3
In case of form authentication, lists are there in 'credential' element of web.config file.
User lists for windows authentication are found in 'authorization' element
4
There is no such classification available in Forms authentication.
There are four different kinds of Windows authentication options available that can be configured in IIS
1)Integrated Windows authentication
2) Basic and basic with SSL authentication
3) Digest authentication
4) Client Certificate authentication

No comments:

Post a Comment