Monday, January 30, 2012

.Net Interview Questions

.NET Interview Questions

Main differences between .NET 1.1, 2.0, 3.0 and 3.5

Chapter 1: Basic .NET Framework
(B)What is an IL?
(B)What is a CLR?
(B)What is CTS?
(B)What is a CLS (Common Language Specification)?
(B)What is a Managed Code?
(B)What is a Assembly?
(A) What are the different types of Assembly?
(B) What is NameSpace?
(B) What is Difference between NameSpace and Assembly?
(A) If you want to view an Assembly how do you go about it?
(A) What is Manifest?
(B) Where is version information stored of an assembly?
(I) Is versioning applicable to private assemblies?
(B) What is GAC?
(I) what is the concept of strong names?
(I) How to add and remove an assembly from GAC?
(B) What is Delay signing?
(B) What is garbage collection?
(I) Can we force garbage collector to run?
(B) What is reflection?
(A) What are different types of JIT?
(B) What are Value types and Reference types?
(B) What is concept of Boxing and Unboxing ?
(B) What is the difference between VB.NET and C#?
(I) what is the difference between System exceptions and Application exceptions?
(I)What is CODE Access security?
(I)What is a satellite assembly?
(A) How to prevent my .NET DLL to be decompiled?
(I) what is the difference between Convert.toString and .toString () method?
(A) What is Native Image Generator (Ngen.exe)?
(A) If we have two version of same assembly in GAC how do we make a choice?
(A)What is CodeDom?
Chapter 2: NET Interoperability
(I) How can we use COM Components in .NET?
(I) We have developed the COM wrapper do we have to still register the COM?
(A)How can we use .NET components in COM?
(A) How can we make Windows API calls in .NET?
(B) When we use windows API in .NET is it managed or unmanaged code?
(I)What is COM?
(A) What is Reference counting in COM?
(A) Can you describe IUKNOWN interface in short?
(I) Can you explain what DCOM is?
(B) How do we create DCOM object in VB6?
(A) How to implement DTC in .NET?
(A) How many types of Transactions are there in COM + .NET?
(A) How do you do object pooling in .NET?
(A) What are types of compatibility in VB6?
(A)What is equivalent for regsvr32 exe in .NET?
Chapter 3: Threading
(B) What is Multi-tasking?
(B) What is Multi-threading?
(B) What is a Thread?
(B) Did VB6 support multi-threading?
(B)Can we have multiple threads in one App domain?
(B) Which namespace has threading?
(A) What does Address Of operator do in background?
(A) How can you reference current thread of the method?
(I) what is Thread.Sleep () in threading?
(A) How can we make a thread sleep for infinite period?
(A) What is Suspend and Resume in Threading?
(A) What the way to stop a long running thread?
(A) How do I debug thread?
(A) What is Thread.Join () in threading?
(A) What are Daemon threads and how can a thread be created as Daemon?
(A) How is shared data managed in threading?
(I) Can we use events with threading?
(A) How can we know a state of a thread?
(A) What is use of Interlocked class ?
(A) What is a monitor object?
(A) What are wait handles?
(A) What is ManualResetEvent and AutoResetEvent?
(A) What is Reader Writer Locks?
(I) How can you avoid deadlock in threading?
(B) What is the difference between thread and process?
Chapter 4: Remoting and Webservices
(B)What is an application domain?
(B) What is .NET Remoting?
(B) Which class does the remote object has to inherit?
(I) what are two different types of remote object creation mode in .NET ?
(A) Describe in detail Basic of SAO architecture of Remoting?
(A) What are the situations you will use singleton architecture in remoting?
(A) What is fundamental of published or precreated objects in Remoting?
(A) What are the ways in which client can create object on server in CAO model?
(A) Are CAO stateful in nature?
(A) To create objects in CAO with ‘new’ keyword what should be done?
(I) Is it a good design practice to distribute the implementation to Remoting Client?
(A) What are LeaseTime, SponsorshipTime, RenewonCallTime and
LeaseManagerPollTime?
(A) Which config file has all the supported channels/protocol?
(A) How can you specify remoting parameters using Config files?
(A) Can Non-Default constructors be used with Single Call SAO?
(I) How can we call methods in remoting asynchronously?
(A) What is Asynchronous One-Way Calls?
(B) What is marshalling and what are different kinds of marshalling?
(A) What is ObjRef object in remoting?
(B) What is a Web Service?
(B) What is UDDI?
(B) What is DISCO?
(B) What is WSDL?
(A) What the different phase/steps of acquiring a proxy object in Web service?
(A) What the different phase/steps of acquiring a proxy object in Web service?
(B) What is file extension of Web services?
(B) Which attribute is used in order that the method can be used as WebService?
(A) What are the steps to create a web service and consume it?
(A) Do webservice have state?
Chapter 5: Caching Concepts
(B) What is an application object?
(I) what is the difference between Cache object and application object?
(I) How can get access to cache object?
(A) What are dependencies in cache and types of dependencies?
(A)Can you show a simple code showing file dependency in cache?
(A) What is Cache Callback in Cache?
(A) What is scavenging?
(B) What are different types of caching using cache object of ASP.NET?
(B) How can you cache different version of same page using ASP.NET cache object?
(A) How will implement Page Fragment Caching?
(B) Can you compare ASP.NET sessions with classic ASP?
(B) Which are the various modes of storing ASP.NET session?
(A) Is Session_End event supported in all session modes?
(A) What are the steps to configure StateServer Mode?
(A) What are the steps to configure SQLServer mode?
(A) Where do you specify session state mode in ASP.NET?
(B) What are the other ways you can maintain state?
(B) What are benefits and Limitation of using Hidden fields?
(B) What is ViewState?
(A) Does the performance for viewstate vary according to User controls?
(B) What are benefits and Limitation of using Viewstate for state management?
(B) How can you use Hidden frames to cache client data ?
(I) What are benefits and limitations of using Hidden frames?
(I) What are benefits and limitations of using Cookies?
(I) What is Query String and What are benefits and limitations of using Query Strings?
(I) What is Absolute and Sliding expiration?
(I) What is cross page posting? 93
(I) How do we access viewstate value of this page in the next page ?
(I) Can we post and access view state in another application?
(I) What is SQL Cache Dependency in ASP.NET 2.0?
(I) How do we enable SQL Cache Dependency in ASP.NET 2.0?
(I) What is Post Cache substitution?
(I) Why do we need methods to be static for Post Cache substitution?
Chapter 6: OOPS
(B) What is Object Oriented Programming?
(B) What is a Class?
(B) What is an Object?
(A) What is the relation between Classes and Objects?
(B) What are different properties provided by Object-oriented systems?
(B) How can we achieve inheritance in VB.NET?
(I) what are abstract classes?
(B) What is a Interface?
(A) What is difference between abstract classes and interfaces?
(B) What is a delegate?
(B) What are Events?
(I) Do events have return type.
(A) Can events have access modifiers?
(A) Can we have shared events?
(I) what is shadowing?
(A) What is the difference between Shadowing and Overriding?
(I) what is the difference between delegate and events?
(B) If we inherit a class do the private variables also get inherited?
(B) What is the different accessibility levels defined in .NET?
(I) Can you prevent a class from overriding?
(I) what is the use of “Must inherit” keyword in VB.NET?
(I) Do interface have accessibility modifier.
(A) What are similarities between Class and structure?
(A) What is the difference between Class and structure’s?
(B) What does virtual keyword mean?
(B) What are shared (VB.NET)/Static(C#) variables?
(B) What is Dispose method in .NET?
(B) What is the use of “Overrides” and “Overridable” keywords?
(A)Where are all .NET Collection classes located?
(A) What is ArrayList?
(A) What is a HashTable?
(A) What are queues and stacks?
(B) What is ENUM?
(A) What is nested Classes?
(B)What is Operator overloading in .NET?
(I) For the below code which constructor will fire first?
(B)What is the significance of Finalize method in .NET?
(I)How can we suppress a finalize method?
(B)What is the use of DISPOSE method?
A) How do I force the Dispose method to be called automatically, as clients can forget to
call Dispose method?
(I) In what instances you will declare a constructor to be private?
(I) Can we have different access modifiers on get/set methods of a property ?
(I) If we write a goto or a return statement in try and catch block will the finally block
execute?
(A) What is Indexer?
(A) Can we have static indexer in C#?
(A)Can two catch blocks be executed?
(A) What is the difference between System.String and System.StringBuilder classes?
Chapter 7: ASP.NET
(B) What’ is the sequence in which ASP.NET events are processed?
(B) In which event are the controls fully loaded?
(B) How can we identify that the Page is Post Back?
(B) How does ASP.NET maintain state in between subsequent request?
(A) What is event bubbling?
B) How do we assign page specific attributes?
(A) How do we ensure viewstate is not tampered?
(B) What is the use of @ Register directives?
(B) What is the use of Smart Navigation property?
(B) What is AppSetting Section in “Web.Config” file?
(B) Where is View State information stored?
(I) what is the use of @ Output Cache directive in ASP.NET.
(B) How can we create custom controls in ASP.NET?
(B) How many types of validation controls are provided by ASP.NET?
(B) Can you explain “AutoPostBack”?
(B) How can you enable automatic paging in Data Grid?
(B) What is the use of “GLOBAL.ASAX” file?
(B) What is the difference between “Web.config” and “Machine.Config”?
(B) What is a SESSION and APPLICATION object?
(A) What is the difference between ‘Server.Transfer’ and ‘response. Redirect’ ?
(A)What is the difference between Authentication and authorization?
(I) what is impersonation in ASP.NET?
(B) Can you explain in brief how the ASP.NET authentication process works?
(A) What are the various ways of authentication techniques in ASP.NET?
(A)How does authorization work in ASP.NET?
(B)What is difference between Data grid, Datalist, and repeater?
(A)From performance point of view, how do they rate?
(B)What is the method to customize columns in Data Grid?
(B)How can we format data inside Data Grid?
(A) How to decide on the design consideration to take a Data grid, data list, or repeater?
(B) Difference between ASP and ASP.NET?
(A) What are major events in GLOBAL.ASAX file?
(A) What order they are triggered?
(I) Do session use cookies?
(I)How can we force all the validation control to run?
(B)How can we check if all the validation control are valid and proper?
(A) If client side validation is enabled in your Web page, does that mean server side code
is not run.
(A)Which JavaScript file is referenced for validating the validators at the client side?
(B)How to disable client side script in validators?
(A)How can I show the entire validation error message in a message box on the client
side?
(B)You find that one of your validations is very complicated and does not fit in any of the
validators, what will you do?
(I)What exactly happens when ASPX page is requested from a browser?
(B) How can we kill a user session?
(I) How do you upload a file in ASP.NET?
(I) How do I send email message from ASP.NET?
(A)What are different IIS isolation levels?
(A)ASP used STA threading model, what is the threading model used for ASP.NET.
(A)What is the use of <%@ page aspcompat=true %> attribute?
B) Explain the differences between Server-side and Client-side code?
(I)Can you explain Forms authentication in detail?
(A)How do I sign out in forms authentication?
(A)If cookies are not enabled at browser end does form Authentication work?
(A)How to use a checkbox in a data grid?
(I)What are the steps to create a windows service in VB.NET?
(A) What is the difference between “Web farms” and “Web garden”?
(A) How do we configure “Web Garden”?
(B) What is the main difference between Grid layout and Flow Layout?
(I) What’s the difference between trace and debug in ASP.NET?
(A) How do you enable tracing in on an ASP.NET page?
(B) Which namespace is needed to implement debug and trace ?
(A) Can you explain the concept of trace listener?
(I) What are trace switches?
Chapter 8: NET Architecture
(B) What are design patterns?
(A) What is the difference between Factory and Abstract Factory Patterns?
(I)What is MVC pattern?
(A)How can we implement singleton pattern in .NET?
(A)How do you implement prototype pattern in .NET?
(I)What are the situations you will use a Web Service and Remoting in projects?
(A)Can you give a practical implementation of FAƇADE patterns?
(I) How can we implement observer pattern in .NET?
(B)What is three-tier architecture?
(I)Have you ever worked with Microsoft Application Blocks, if yes then which?
(A)What is Service Oriented architecture?
(I)What are different ways you can pass data between tiers?
(A)What is Windows DNA architecture?
(A)What is aspect oriented programming?
Chapter 9: ADO.NET
(B) What is the namespace in which .NET has the data functionality class?
(B) Can you give an overview of ADO.NET architecture?
(B) What are the two fundamental objects in ADO.NET?
(B) What is difference between dataset and data reader?
(I) What are major difference between classic ADO and ADO.NET?
(B) What is the use of connection object?
(B) What is the use of command objects?
(B)What is the use of data adapter?
(B)What are basic methods of Data adapter?
(B) What is Dataset object?
(B) What are the various objects in Dataset?
(B) How can we connect to Microsoft Access, FoxPro, and Oracle etc?
(B) How do we connect to SQL SERVER, which namespace do we use?
(B) How do we use stored procedure in ADO.NET and how do we provide parameters to
the stored procedures?
(B) How can we force the connection object to close after my data reader is closed?
(B) I want to force the data reader to return only schema of the data store rather than data.
(B) How can we fine-tune the command object when we are expecting a single row?
(B) Which is the best place to store connection string in .NET projects?
(B) What are the steps involved to fill a dataset?
(B)What are the various methods provided by the dataset object to generate XML?
(B) How can we save all data from dataset?
(B) How can we check that some changes have been made to dataset since it was loaded?
(B) How can we add/remove row is in “Data Table” object of “Dataset”?
(B) What is basic use of “Data View”?
(B) What is the difference between “Dataset” and “Data Reader” ?
(B) How can we load multiple tables in a Dataset?
(B) How can we add relation between tables in a Dataset?
(B) What is the use of Command Builder?
(B) What’s difference between “Optimistic” and “Pessimistic” locking ?
(A) How many ways are there to implement locking in ADO.NET?
(A)How can we perform transactions in .NET?
(I) What is difference between Dataset? Clone and Dataset. Copy?
(A) Can you explain the difference between an ADO.NET Dataset and an ADO Record
set?
(A) Explain in detail the fundamental of connection pooling?
(A)What is Maximum Pool Size in ADO.NET Connection String?
(A)How to enable and disable connection pooling?
(I) What extra features does ADO.Net 2.0 have ?
Chapter 10: SQL SERVER
(B) What is normalization? What are different types of normalization?
(B) What is denormalization?
(B) What is a candidate key?
(B) What are the different types of joins? What is the difference between them?
(I)What are indexes? What is the difference between clustered and nonclustered indexes?
(A)How can you increase SQL performance?
(A)What is the use of OLAP?
(A)What is a measure in OLAP?
(A)What are dimensions in OLAP?
(A)What are levels in dimensions?
(A)What are fact tables and dimension tables in OLAP?
(A)What is DTS?
(A)What is fill factor ?
(A)What is RAID and how does it work?
(B)What is the difference between DELETE TABLE and TRUNCATE TABLE
commands?
(B)If locking is not implemented, what issues can occur?
(B)What are different transaction levels in SQL SERVER?
(I)What are the different locks in SQL SERVER?
(I) Can we suggest locking hints to SQL SERVER?
(I) What is LOCK escalation?
(B) What are the different ways of moving data between databases in SQL Server?
(I) What are advantages of SQL 2000 over SQl 7.0?
(B) What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
(B) What is the difference between UNION and UNION ALL SQL syntax?
(I) How can you raise custom errors from stored procedure?
(I) what is ACID fundamental? What are transactions in SQL SERVER?
(A) What is DBCC?
(A) What is the purpose of Replication?
(A) What are the different types of replication supported by SQL SERVER?
(I) What is BCP utility in SQL SERVER?
(I)What are the different types of triggers in SQl SERVER?
(A)If we have multiple AFTER Triggers on table how can we define the sequence of the
triggers?
(A)What is SQL injection?
(B) What is the difference between Stored Procedure (SP) and User Defined Function
(UDF)?
Chapter 11: UML
(B) What is UML?
(I) How many types of diagrams are there in UML?
(B) What are advantages of using UML?
(A)What is the sequence of UML diagrams in project?
(A)Give a small brief explanation of all Elements in activity diagrams?
(A)Explain Different elements of a collaboration diagram?
(A) Explain all parts of a deployment diagram?
(A) Describe the various components in sequence diagrams?
(A) What are the elements in State Chart diagrams?
(A)Describe different elements in Static Chart diagrams?
(A)Explain the different elements of a Use Case?
Chapter 12: Project Management
(B) What is project management?
(A) Is spending in IT projects constant through out the project?
(B) Who is a stakeholder?
(B) Can you explain project life cycle?
(B) Are risk constant through out the project?
(A) Can you explain different software development life cycles?
(B) What is triple constraint triangle in project management?
(B) What is a project baseline?
(B) What is effort variance?
(B) How is normally a project management plan document organized?
(I)How do you estimate a project?
(B)What is CAR (Causal Analysis and Resolution)?
(B) What is DAR (Decision Analysis and Resolution)?
(B) What is a fish bone diagram?
(B) What is Pareto principle?
(B) How do you handle change request?
(I) What is internal change request?
(B) What is difference between SITP and UTP in testing?
(B) Which software have you used for project management?
(I) What are the metrics followed in project management?
(B)People in your project do not peform , what will you do?
(B)What is black box testing and White box testing?
(B) What is the difference between Unit testing, Assembly testing and Regression
testing?
(I) What is V model in testing?
(B)How do you start a project?
(B)How did you do resource allocations?
(I) How will you do code reviews?
(A)What is CMMI?
(A) What are the five levels in CMMI?
(A) What is continuous and staged representation?
(A)What is SIX sigma?
(A)What are DMAIC and DMADV?
(A)What are the various roles in Six Sigma implementation?
(I)What are function points?
(I)What are the different types of elementary process in FPA?
(I)What are the different elements in Functions points?
(A) Can you explain in GSC and VAF in function points?
(I) What are unadjusted function points and how is it calculated?
(I) Can you explain steps in function points?
(I) What is the FP per day in your current company?
(A)Do you know Use Case points?
(A)What is COCOMO I, COCOMOII and COCOMOIII?
(A) What is SMC approach of estimation?
(A)How do you estimate maintenance project and change requests?
Chapter 13: XML
(B) What is XML?
(I) What is the version information in XML?
(B) What is ROOT element in XML?
(B) If XML does not have closing tag will it work?
(B) Is XML case sensitive?
(B) What is the difference between XML and HTML?
(B) Is XML meant to replace HTML?
(A) Can you explain why your project needed XML?
(B) What is DTD (Document Type Definition)?
(B) What is well formed XML?
(B) What is a valid XML?
(B) What is CDATA section in XML?
(B) What is CSS?
(B) What is XSL?
(B) What is element and attributes in XML?
(B) Which are the namespaces in .NET used for XML?
(A) What are the standard ways of parsing XML document?
(A)In What scenarios will you use a DOM parser and SAX parser?
(A) How was XML handled during COM times?
(A)What is the main difference between MSML and .NET Framework XML classes?
(B) What are the core functionalities in XML .NET framework? Can you explain in detail
those functionalities?
(B )What is XSLT?
(I) Define XPATH?
(A) What is the concept of XPOINTER?
(B) What is an XMLReader Class?
(B) What is XMLTextReader?
(I) How do we access attributes using “XmlReader”?
(I) Explain simple Walk through of XmlReader.
(A) What does XmlValidatingReader class do?
Chapter 14: Localization/Globalization
(B) What is Unicode & Why was it introduced?
(I) Does .NET support UNICODE and how do you know it supports?
(A) What is the difference between localization and globalization?
(A)What architecture decisions you should consider while planning for international
software’s?
(I) How do we get the current culture of the environment in windows and ASP.NET?
(B) Which are the important namespaces during localization and globalization?
(B) What are resource files and how do we generate resource files?
(I) Can resource file be in any other format other than resx extensions?
(I) How is resource files actually used in project?
(A) How can we use Culture Auto in project?
(B) What are satellite assemblies?
(A) How do we generate Satellite assemblies?
(A) What is AL.EXE and RESGEN.EXE? 275
(I) What is the use of resource manager class?
(A) What precautions do we need to take while deploying satellite assemblies?
(A) Can we get a strongly typed resource class rather than using resource manager?
(A) Can you explain the fundamentals of “GetGlobalResourceObject” and
“GetLocalResourceObject” functions?
(A) Can we sign a satellite assembly?
(I) Can you explain collation sequence in sql server?
(A)How do we define collation sequence for database and tables?
(A)Can we change the order in a select query with a specified collation sequence?
(A) Can you list best practices for globalization and localization?
(A) Why is the culture set to the current thread?
Chapter 15: Windows Communication Foundation
(Vista Series)
(I) What are the important principles of SOA (Service oriented Architecture)?
(I) What are ends, contract, address, and bindings?
(A) Which specifications does WCF follow?
(A) What are the main components of WCF?
(I) Explain how Ends, Contract, Address, and Bindings are done in WCF?
(I) what is a service class?
(I) what is a service contract, operation contract and Data Contract?
(I) what are the various ways of hosting a WCF service?
(I) How do we host a WCF service in IIS?
(I) what are the advantages of hosting WCF Services in IIS as compared to self-hosting?
(I) what are the major differences between services and Web services?
(I) What is the difference WCF and Web services?
(A) What are different bindings supported by WCF?
(A) Which are the various programming approaches for WCF?
(A) What is one-way operation?
(A) Can you explain duplex contracts in WCF?
(A) How can we host a service on two different protocols on a single server?
(A) How can we use MSMQ bindings in WCF?
(A) Can you explain transactions in WCF?
(A) What different transaction isolation levels provided in WCF?
(A) Can we do transactions using MSMQ?
(A)Can we have two-way communications in MSMQ?
(A) What are Volatile queues?
(A) What are Dead letter queues?
(A) What is a poison message?
Chapter 16: Windows Presentation Framework (Vista Series)
(B) What is WPF?
(B) What is XAML?
(I) What are dependency properties?
(A) Are XAML file compiled or built on runtime?
(B) Can you explain how we can separate code and XAML?
B) How can we access XAML objects in behind code?
(A) What kind of documents are supported in WPF?
Chapter 17: Windows workflow foundation
(Vista series)
(B) What is Windows Workflow Foundation?
(B) What is a Workflow?
(B) What are different types of Workflow in Windows Workflow foundation?
(I) when should we use a sequential workflow and when should we use state machines?
(I) How do we create workflows using designer?
(I) How do we specify conditions in Work flow?
(I) How do you handle exceptions in workflow?
(I) What is the use of XOML files.
(A) How can we pass parameters to workflow?
Chapter 18: ATLAS-AJAX
(B) What problem does Ajax solve?
(B) What is Ajax?
(B) What is the fundamental behind Ajax?
(B) What is JSON?
(B) How do we use XMLHttpRequest object in JavaScript?
(B) How do we do asynchronous processing using Ajax?
(B) What are the various states in XMLHttpRequest and how do we check the same?
(B) How can we get response text?
(B) How can we send request to the server using the XMLHttpRequest component?
(I) How do we pass parameters to the server?
(I) How can we create a class in JavaScript using Atlas?
(A) How do we do inheritance-using Atlas?
(A) How do we define interfaces using Atlas?
(A) How do we reference HTML controls using Atlas?
(I) Can you explain Scriptmanager control in Ajax?
(B) Can you explain Enablepartialrendering and UpdatePanel control in Ajax?
(I) Can you explain the concept of triggers in ‘UpdatePanel’ control?
(I) Can you explain the ‘UpdateProgress’ component?
(A) How can you do validations in Ajax?
(A) How do we do exception handling in Ajax?
(A) How do we consume web service in Atlas?
(A) How can we consume data directly in web services?
Chapter 19:- Reports
(B) How do we access crystal reports in .NET?
(I) What are the various components in crystal reports?
(I) What basic steps are needed to display a simple report in crystal?
(I) Can crystal reports be published as a web service?
(I) How do we invoke the crystal report web service?
(I) How do we add formulas using crystal reports?
(I) How do we pass parameters to crystal reports?
(I) How do we export from crystal reports?
(I) How do we print to printer using crystal?
(I) How do we generate cross tab reports?
(A) How can we do grouping in crystal?
(A) Can you explain three-pass reporting which crystal report uses?
(B) Can you explain reporting services architecture?
(B) We have two IIS application ‘Reports’ and ‘Reportserver’ what do they do ?
(A) Can you explain Report definition language (RDL) file in reporting services?
(B) What is the basic process of making a report in reporting services?
(B) How can we consume reports in ASP.NET?
(I) Can you explain the difference between private and shared data sources?
(A) How does reports caching in reporting services work ?
(I) What are the major differences between Crystal and SQL reporting services?
Chapter 20:- ASP.NET 2.0
(I) What improvements are provided in ASP.NET 2.0?
(I) How does ASP.NET 2.0 eliminate tedious coding?
(I) How do we encrypt web.config files in ASP.NET 2.0 ?
(A) With the above technique can you encrypt everything in the web.config file?
(A) In .NET 1.X how was the encryption implemented for config files?
(B) Can you explain membership and role providers in ASP.Net 2.0?
(I) What kind of security web controls are introduced in ASP.NET 2.0?
(I) Can you explain master pages concept in ASP.NET?
(I) what is the concept of Web parts?
(A) What are the different components of the web part framework?
(I) What are partial classes in ASP.NET ?
(I) Can you explain generics in .NET ?
(I) Can you explain the concept of generic collection?
Chapter 21:- How to
(B) How do you send a email using ASP.NET?
(B) How did you deployment and setup in ASP.NET?
Chapter 22:- .NET 3.5
(I) Define LINQ ?
(I) We already have common data access model what is special about LINQ?
(I) How can you make entity classes from the table itself ?
(A) How can we transform LINQ to objects ?
(A) How to transform LINQ to ADO.NET ?
(A) How to transform LINQ to SQL ?
(A) How to transform LINQ to XML ?
(A) How to transform LINQ to entities ?
(A) Can you explain Delegate Instantiation?
(A) Can you explain Anonymous methods ?
(A) What is Yield in LINQ ?
(A) Can you explain Lambda Expressions ?
(A) What are Instance methods and Extension methods ?
(A) What are Anonymous types ?
(A) Revision of Simple Query syntax for LINQ ?
(I) What is silver light?

Forms Authentication

In Web Config:       

<authentication mode="Forms">
            <forms loginUrl="~/Default.aspx">
                <credentials passwordFormat="Clear">
                    <user name="user" password="password"/>
                    <user name="user2" password="password2"/>
          <user name="karthi" password="karthi"/>
                </credentials>
            </forms>
        </authentication>


In aspx.cs :

string username = txt1.Text;
            string password = txt2.Text;

            Response.Cache.SetCacheability(HttpCacheability.NoCache);

                        

            if (FormsAuthentication.Authenticate(username, password))
                FormsAuthentication.RedirectFromLoginPage(username,true );
                     

         div1.InnerHtml  = "<font size=5 color=red><i><b>Invalid user</b></i></font>";







Tuesday, January 17, 2012

Best method for writing in excel using EPPlus

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OfficeOpenXml;
using System.Drawing;
using OfficeOpenXml.Style;
using System.Data;



namespace WebApplication5
{
    public partial class SampleExcel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            try
            {
                using (ExcelPackage pck = new ExcelPackage())
                {
                    //Create the worksheet
                    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

                    //or use this
                    //ExcelWorkbook wb = pck.Workbook;
                    //ExcelWorksheet ws1 = wb.Worksheets.Add("Demo");


                    AddRecords(ws);

                    pck.Workbook.Properties.Title = "Excel Export";
                    pck.Workbook.Properties.Author = "Me";
                    pck.Workbook.Properties.Comments = "Sample Record Details";
                    pck.Workbook.Properties.Company = "ABC Tech";


                    byte[] fileBytes = pck.GetAsByteArray();

                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.ClearContent();
                    HttpContext.Current.Response.ClearHeaders();
                    HttpContext.Current.Response.Cookies.Clear();

                    //Add the header & other information
                    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
                    HttpContext.Current.Response.CacheControl = "private";
                    HttpContext.Current.Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
                    HttpContext.Current.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
                    HttpContext.Current.Response.AppendHeader("Content-Length", fileBytes.Length.ToString());
                    HttpContext.Current.Response.AppendHeader("Pragma", "cache");
                    HttpContext.Current.Response.AppendHeader("Expires", "60");

                    string DateTimes = DateTime.Now.TimeOfDay.ToString().Replace(":", "_").Replace(".", "_");

                    //Default Download Filename
                    string FileName = "ExportBiblio_" + DateTimes + ".xlsx";

                    HttpContext.Current.Response.AppendHeader("Content-Disposition",
                    "attachment; " +
                    "filename=\"" + FileName + "\"; " +
                    "size=" + fileBytes.Length.ToString() + "; " +
                    "creation-date=" + DateTime.Now.ToString("R") + "; " +
                    "modification-date=" + DateTime.Now.ToString("R") + "; " +
                    "read-date=" + DateTime.Now.ToString("R"));
                    HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.sampleDemo.sheet";

                    //Write it back to the client
                    HttpContext.Current.Response.BinaryWrite(fileBytes);
                    HttpContext.Current.Response.End();


                }
            }

            catch (Exception ex)
            {
                ex.ToString();

            }

           

        }



 

        public  void AddRecords(ExcelWorksheet _Wsheet1)
        {

             _Wsheet1.Column(1).Width = 15;
              _Wsheet1.Column(2).Width = 25;
                 _Wsheet1.Column(3).Width = 20;

   
             _Wsheet1.Cells["B2"].Value = "EmpNo ";
            _Wsheet1.Cells["B2"].Style.Font.Bold = true;
            _Wsheet1.Cells["C2"].Value = "111";




            _Wsheet1.Cells["C2"].Style.Font.Color.SetColor(Color.FromArgb(0, 112, 192));
            _Wsheet1.Cells["C2"].Style.Font.Bold = true;
            _Wsheet1.Cells["C2"].Style.Font.Size = 14;



            _Wsheet1.Cells["B3"].Value = "EmpName";
            _Wsheet1.Cells["B3"].Style.Font.Bold = true;           
            _Wsheet1.Cells["C3"].Value ="aaa";
            _Wsheet1.Cells["C3"].Style.WrapText = true;
            _Wsheet1.Cells["C3:G3"].Merge = true;

            _Wsheet1.Cells["C3"].Style.Font.Color.SetColor(Color.FromArgb(0, 112, 192));
            _Wsheet1.Cells["C3"].Style.Font.Bold = true;
            _Wsheet1.Cells["C3"].Style.Font.Size = 14;    



            //_Wsheet1.Cells["B" + (Rowid - 2).ToString() + ":G" + Rowid.ToString()].Style.Fill.BackgroundColor.SetColor(Color.LightGray);
            //_Wsheet1.Cells["B" + (Rowid - 2).ToString() + ":G" + Rowid.ToString()].Style.WrapText = true;

            _Wsheet1.Cells["B1:G2"].Style.Fill.BackgroundColor.SetColor(Color.LightGray);
            _Wsheet1.Cells["B1:G2"].Style.WrapText = true;


            //_Wsheet1.Cells["B" + (Rowid - 2).ToString() + ":G" + Rowid.ToString()].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
            //_Wsheet1.Cells["B" + (Rowid - 2).ToString() + ":G" + Rowid.ToString()].Style.Border.Top.Style = ExcelBorderStyle.Thin;
            //_Wsheet1.Cells["B" + (Rowid - 2).ToString() + ":G" + Rowid.ToString()].Style.Border.Left.Style = ExcelBorderStyle.Thin;
            //_Wsheet1.Cells["B" + (Rowid - 2).ToString() + ":G" + Rowid.ToString()].Style.Border.Right.Style = ExcelBorderStyle.Thin;

       
           _Wsheet1.Cells["B1:G2"].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
            _Wsheet1.Cells["B1:G2"].Style.Border.Top.Style = ExcelBorderStyle.Thin;
           _Wsheet1.Cells["B1:G2"].Style.Border.Left.Style = ExcelBorderStyle.Thin;
            _Wsheet1.Cells["B1:G2"].Style.Border.Right.Style = ExcelBorderStyle.Thin;

           
              var CellVal = _Wsheet1.Cells["C1"].RichText;



                var part = CellVal.Add("A");
                part.Color = Color.Blue;



}
        
       
            }
        }


Reading Excel using EPPlus


      ExcelPackage excelPackage;
       ExcelWorkbook myWorkbook;
       string SheetName = "Demo";
       string cell = "";
       string tmpFileName = "log";

       string main_ref_no = "";
       string tempDktNo = "";

       ImportProcess objImportProcess = new ImportProcess();
FileInfo existingFile = new FileInfo(@"D:\\Sample\DemoFile.xlsx");

using (excelPackage = new ExcelPackage(existingFile))
           {
                           
              myWorkbook = excelPackage.Workbook;
if (myWorkbook.Worksheets[SheetName].Cells[cell].Value != null)
             {
string var = myWorkbook.Worksheets[SheetName].Cells[ColumnID[ColNo] + "1"].Value.ToString();

string var1 = myWorkbook.Worksheets[SheetName].Cells["C" + RowNo].Value.ToString();
//string var = myWorkbook.Worksheets[SheetName].Cells["A1"].Value.ToString();
}
}

//string.Format("{0:000000}",123);






EPPlus Sample for writing

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OfficeOpenXml;
using System.Drawing;
using OfficeOpenXml.Style;
using System.Data;



namespace WebApplication5
{
    public partial class SampleExcel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            DataTable dt = new DataTable();
            dt.Columns.Add("EmpNo");
            dt.Columns.Add("EmpName");
            dt.Columns.Add("EmpDept");
            dt.Rows.Add("111", "aaa", "bbb");
            dt.Rows.Add("222", "aaa", "bbb");
            dt.Rows.Add("333", "aaa", "bbb");
            dt.Rows.Add("444", "aaa", "bbb");
            dt.Rows.Add("555", "aaa", "bbb");
            dt.AcceptChanges();
            DumpExcel(dt);

           

        }



        private void DumpExcel(DataTable tbl)
        {

            try
            {
                using (ExcelPackage pck = new ExcelPackage())
                {
                    //Create the worksheet
                    ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Demo");

                    //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                    ws.Cells["A1"].LoadFromDataTable(tbl, true);

                    //Format the header for column 1-3
                    using (ExcelRange rng = ws.Cells["A1:C1"])
                    {
                        rng.Style.Font.Bold = true;
                        rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
                        rng.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(79, 129, 189));  //Set color to dark blue
                        rng.Style.Font.Color.SetColor(Color.White);
                    }

                    //Example how to Format Column 1 as numeric
                    using (ExcelRange col = ws.Cells[2, 1, 2 + tbl.Rows.Count, 1])
                    {
                        col.Style.Numberformat.Format = "#,##0.00";
                        col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                    }





                    //Write it back to the client
                    //Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    //Response.AddHeader("content-disposition", "attachment;  filename=ExcelDemo.xlsx");
                    //Response.BinaryWrite(pck.GetAsByteArray());


                    pck.Workbook.Properties.Title = "Excel Export";
                    pck.Workbook.Properties.Author = "Me";
                    pck.Workbook.Properties.Comments = "Sample Record Details";
                    pck.Workbook.Properties.Company = "ABC Tech";


                    byte[] fileBytes = pck.GetAsByteArray();

                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.ClearContent();
                    HttpContext.Current.Response.ClearHeaders();
                    HttpContext.Current.Response.Cookies.Clear();

                    //Add the header & other information
                    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Private);
                    HttpContext.Current.Response.CacheControl = "private";
                    HttpContext.Current.Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
                    HttpContext.Current.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
                    HttpContext.Current.Response.AppendHeader("Content-Length", fileBytes.Length.ToString());
                    HttpContext.Current.Response.AppendHeader("Pragma", "cache");
                    HttpContext.Current.Response.AppendHeader("Expires", "60");

                    string DateTimes = DateTime.Now.TimeOfDay.ToString().Replace(":", "_").Replace(".", "_");

                    //Default Download Filename
                    string FileName = "ExportBiblio_" + DateTimes + ".xlsx";

                    HttpContext.Current.Response.AppendHeader("Content-Disposition",
                    "attachment; " +
                    "filename=\"" + FileName + "\"; " +
                    "size=" + fileBytes.Length.ToString() + "; " +
                    "creation-date=" + DateTime.Now.ToString("R") + "; " +
                    "modification-date=" + DateTime.Now.ToString("R") + "; " +
                    "read-date=" + DateTime.Now.ToString("R"));
                    HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.sampleDemo.sheet";

                    //Write it back to the client
                    HttpContext.Current.Response.BinaryWrite(fileBytes);
                    HttpContext.Current.Response.End();

                   
                }
            }

            catch (Exception ex)
            {
                ex.ToString();
            }
        }





    }
}