Tuesday, July 31, 2012

WCF - IMP concepts


Following  concepts are vital for WCF implementation:

1.       End Point
2.       Bindings and Behavior
3.       Contracts and Service host
4.       WCF Client and Metadata
5.       WCF Hosting
- IIS*
- WAS
- Self hosting*
- Windows Service
6.       Instance Management - [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
- Per-Call instance mode
- Per-Session instance mode
- Singleton Instance Mode
7.       Instance Deactivation – (For sessionful service instance) -  [OperationBehavior(ReleaseInstanceMode=ReleaseInstanceMode.BeforeCall]
- RealeaseInstanceMode.None
- RealeaseInstanceMode.BeforeCall
- RealeaseInstanceMode.AfterCall
- RealeaseInstanceMode.BeforeAndAfterCall
8.       Durable Service
- CanCreateInstance = true
- CompletesInstance = true
9.       Throttling
- maxConcurrentCalls
- maxConcurrentInstances
-  maxConcurrentSessions
10.   Operations
- Request- Replay (default)
- One-Way
- Callback - WSDuplexBinding, TCP, IPC
11.   Simplified configuration
12.   Discovery service
13.   Routing service
14.   REST Service

ASP.NET MVC Stuff


ASP.NET MVC  - Session Variables

Global.aspx events

HTML 5 Controls for ASP.NET MVC

ASP.NET MVC Grid Data

ASP.MVC VS ASP.NET 

Wednesday, July 25, 2012

MVC3 QAs


What is MVC?
MVC is a framework methodology that divides an application’s implementation into three component roles:models, views, and controllers.
“Models”
in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have a Productclass that is used to represent order data from the Products table inside SQL).
“Views”
in a MVC based application are the components responsible for displaying the application’s user interface. Typically this UI is created off of the model data (for example: we might create an Product “Edit”view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object).
“Controllers”
in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVCapplication the view is only about displaying information – it is the controller that handles and responds touser input and interaction.
Which are the advantages of using MVC Framework?
MVC is one of the most used architecture pattern in ASP.NET and this is one of those ASP.NET interviewquestion to test that do you really understand the importance of model view controller.1. It provides a clean separation of concerns between UI and model.2. UI can be unit test thus automating UI testing.3. Better reuse of views and model. You can have multiple views which can point to the same model andalso vice versa.4. Code is better organized.
What is Razor View Engine?
Razor view engine is a new view engine created with ASP.Net MVC model using specially designedRazor parser to render the HTML out of dynamic server side code. It allows us to write Compact,Expressive, Clean and Fluid code with new syntaxes to include server side code in to HTML.
What is namespace of asp.net mvc?
ASP.NET MVC namespaces and classes are located in the System.Web.Mvc assembly.
System.Web.Mvc namespace
Contains classes and interfaces that support the MVC pattern for ASP.NET Web applications. Thisnamespace includes classes that represent controllers, controller factories, action results, views, partialviews, and model binders.
System.Web.Mvc.Ajax namespace
Contains classes that support Ajax scripts in an ASP.NET MVC application. The namespace includessupport for Ajax scripts and Ajax option settings.
System.Web.Mvc.Async namespace
Contains classes and interfaces that support asynchronous actions in an ASP.NET MVC application
System.Web.Mvc.Html namespace
Contains classes that help render HTML controls in an MVC application. The namespace includesclasses that support forms, input controls, links, partial views, and validation.
How to identify AJAX request with C# in MVC.NET?
The solution is in depended from MVC.NET framework and universal across server-side technologies.Most modern AJAX applications utilize XmlHTTPRequest to send async request to the server. Suchrequests will have distinct request header:
X-Requested-With = XMLHTTPREQUEST
MVC.NET provides helper function to check for ajax requests which internally inspects X-Requested-Withrequest header to set IsAjax flag.
HelperPage.IsAjax Property
Gets a value that indicates whether Ajax is being used during the request of the Web page.
Namespace:
System.Web.WebPages
Assembly:
System.Web.WebPages.dllHowever, same can be achieved by checking requests header directly:Request["X-Requested-With"] == “XmlHttpRequest”
 
What is Repository Pattern in ASP.NET MVC?
Repository pattern is usefult for decoupling entity operations form presentation, which allows easymocking and unit testing.“The Repository will delegate to the appropriate infrastructure services to get the job done. Encapsulatingin the mechanisms of storage, retrieval and query is the most basic feature of a Repositoryimplementation”“Most common queries should also be hard coded to the Repositories as methods.”
 
Which MVC.NET to implement repository pattern Controller would have 2 constructors on parameterlessfor framework to call, and the second one which takes repository as an input:
class myController: Controller{private IMyRepository repository;
// overloaded constructor
public myController(IMyRepository repository)
{this.repository = repository;}
// default constructor for framework to call
public myController()
{
//concreate implementation
myController(new someRepository());
}
...
public ActionResult Load(){
// loading data from repository
var myData = repository.Load();
}
}

What is difference between MVC(Model-View-Controller) and MVP(Model-View-Presenter)?
The main difference between the two is how the manager (controller/presenter) sits in the overallarchitecture.
All requests goes first to the Controller
MVC pattern puts the controller as the main ‘guy’ in charge for running the show. All application requestcomes through straight to the controller, and it will decide what to do with the request.Giving this level of authority to the controller isn’t an easy task in most cases. Users interaction in anapplication happen most of the time on the View.Thus to adopt MVC pattern in a web application, for example, the url need to become a way of instantiatinga specific controller, rather than ‘simply’ finding the right View (webform/ html page) to render out. Everyrequests need to trigger the instantiation of a controller which will eventually produce a response to theuser.This is the reason why it’s alot more difficult to implement pure
MVC using Asp.Net Webform. The Urlrouting system in Asp.Net webform by default is tied in to the server filesystem or IIS virtual directorystructure. Each of these aspx files are essentially Views which will always get called and instantiated firstbefore any other classes in the project. (Of course I’m overgeneralizing here. Classes like IHttpModule,IHttpHandler and Global.asax would be instantiated first before the aspx web form pages).MVP (Supervising Controller) on the other hand, doesn’t mind for the View to take on a bigger role. View isthe first object instantiated in the execution pipeline, which then responsible for passing any events thathappens on itself to the Presenter.The presenter then fetch the Models, and pass it back to the view for rendering.
What is the ‘page lifecycle’ of an ASP.NET MVC?
Following process are performed by ASP.Net MVC page:
1) App initialization
2) Routing
3) Instantiate and execute controller
4) Locate and invoke controller action
5) Instantiate and render view

How to call javascript function on the change of Dropdown List in ASP.NET MVC?
Create a java-script function:
Call the function:
<%:Html.DropDownListFor(x => x.SelectedProduct,new SelectList(Model.Products, "Value", "Text"),"Please Select a product", new { id = "dropDown1",onchange="selectedIndexChanged()" })%>

How route table is created in ASP.NET MVC?
When an MVC application first starts, the Application_Start() method is called. This method, in turn, callsthe RegisterRoutes() method. The RegisterRoutes() method creates the route table.
 
How do you avoid XSS Vulnerabilities in ASP.NET MVC?
Use thesyntax in ASP.NET MVC instead of usingin .net framework 4.0.
Explain how to access Viewstate values of this page in the next page?
PreviousPage property is set to the page property of the nest page to access the viewstate value of thepage in the next page.
Page poster = this.PreviousPage;
Once that is done, a control can be found from the previous page and its state can be read.
Label posterLabel = poster.findControl("myLabel");string lbl = posterLabel.Text;
How to create dynamic property with the help of viewbag in ASP.NET MVC?
PreviousPage property is set to the page property of the nest page to access the viewstate value of thepage in the next page.
Page poster = this.PreviousPage;
Once that is done, a control can be found from the previous page and its state can be read.
Label posterLabel = poster.findControl("myLabel");string lbl = posterLabel.Text;
What is difference between Viewbag and Viewdata in ASP.NET MVC?
The basic difference between ViewData and ViewBag is that in ViewData instead creating dynamicproperties we use properties of Model to transport the Model data in View and in ViewBag we can createdynamic properties without using Model data.
What is Routing?
A route is a URL pattern that is mapped to a handler. The handler can be a physical file, such as an .aspxfile in a Web Forms application. Routing module is responsible for mapping incoming browser requests toparticular MVC controller actions

Asp.net real time MVC Interview Quesitons with answers


What is MVC?
MVC is a framework methodology that divides an application’s implementation into three component roles: models, views, and controllers.
“Models” in a MVC based application are the components of the application that are responsible for maintaining state. Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL).
“Views” in a MVC based application are the components responsible for displaying the application’s user interface. Typically this UI is created off of the model data (for example: we might create an Product “Edit” view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object).
“Controllers” in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI. In a MVC application the view is only about displaying information – it is the controller that handles and responds to user input and interaction.

What are the 3 main components of an ASP.NET MVC application?
1. M - Model
2. V - View
3. C - Controller

In which assembly is the MVC framework defined?
System.Web.Mvc

Is it possible to combine ASP.NET webforms and ASP.MVC and develop a single web application?
Yes, it is possible to combine ASP.NET webforms and ASP.MVC and develop a single web application.

What does Model, View and Controller represent in an MVC application?
Model: Model represents the application data domain. In short the applications business logic is contained with in the model.

View: Views represent the user interface, with which the end users interact. In short the all the user interface logic is contained with in the UI.

Controller: Controller is the component that responds to user actions. Based on the user actions, the respective controller, work with the model, and selects a view to render that displays the user interface. The user input logic is contained with in the controller.

What is the greatest advantage of using asp.net mvc over asp.net webforms?
It is difficult to unit test UI with webforms, where views in mvc can be very easily unit tested.

Which approach provides better support for test driven development - ASP.NET MVCor ASP.NET Webforms?
ASP.NET MVC
What is Razor View Engine?
Razor view engine is a new view engine created with ASP.Net MVC model using specially designed Razor parser to render the HTML out of dynamic server side code. It allows us to write Compact, Expressive, Clean and Fluid code with new syntaxes to include server side code in to HTML.


What are the advantages of ASP.NET MVC?
1. Extensive support for TDD. With asp.net MVC, views can also be very easily unit tested.
2. Complex applications can be easily managed
3. Seperation of concerns. Different aspects of the application can be divided into Model, View and Controller.
4. ASP.NET MVC views are light weight, as they donot use viewstate.

Is it possible to unit test an MVC application without running the controllers in an ASP.NET process?
Yes, all the features in an asp.net MVC application are interface based and hence mocking is much easier. So, we don't have to run the controllers in an ASP.NET process for unit testing.
What is namespace of asp.net mvc?
ASP.NET MVC namespaces and classes are located in the System.Web.Mvc assembly.
System.Web.Mvc namespace 
Contains classes and interfaces that support the MVC pattern for ASP.NET Web applications. This namespace includes classes that represent controllers, controller factories, action results, views, partial views, and model binders.
System.Web.Mvc.Ajax namespace 
Contains classes that support Ajax scripts in an ASP.NET MVC application. The namespace includes support for Ajax scripts and Ajax option settings.
System.Web.Mvc.Async namespace 
Contains classes and interfaces that support asynchronous actions in an ASP.NET MVCapplication
System.Web.Mvc.Html namespace 
Contains classes that help render HTML controls in an MVC application. The namespace includes classes that support forms, input controls, links, partial views, and validation.

Is it possible to share a view across multiple controllers?
Yes, put the view into the shared folder. This will automatically make the view available across multiple controllers.

What is the role of a controller in an MVC application?
The controller responds to user interactions, with the application, by selecting the action method to execute and alse selecting the view to render.

Where are the routing rules defined in an asp.net MVC application?
In Application_Start event in Global.asax

Name a few different return types of a controller action method?
The following are just a few return types of a controller action method. In general an action method can return an instance of a any class that derives from ActionResultclass.
1. ViewResult
2. JavaScriptResult
3. RedirectResult
4. ContentResult
5. JsonResult
What is the ‘page lifecycle’ of an ASP.NET MVC?
Following process are performed by ASP.Net MVC page:
1) App initialization
2) Routing
3) Instantiate and execute controller
4) Locate and invoke controller action
5) Instantiate and render view

What is the significance of NonActionAttribute?
In general, all public methods of a controller class are treated as action methods. If you want prevent this default behaviour, just decorate the public method with NonActionAttribute.

What is the significance of ASP.NET routing?
ASP.NET MVC uses ASP.NET routing, to map incoming browser requests to controller action methods. ASP.NET Routing makes use of route table. Route table is created when your web application first starts. The route table is present in the Global.asax file.
How route table is created in ASP.NET MVC?
When an MVC application first starts, the Application_Start() method is called. This method, in turn, calls the RegisterRoutes() method. The RegisterRoutes() method creates the route table.

What are the 3 segments of the default route, that is present in an ASP.NET MVCapplication?
1st Segment - Controller Name
2nd Segment - Action Method Name
3rd Segment - Parameter that is passed to the action method

Example
http://nareshkamuni.blogspot.in/search/label/MVC 
Controller Name = search
Action Method Name = label
Parameter Id = MVC

ASP.NET MVC application, makes use of settings at 2 places for routing to work correctly. What are these 2 places?
1. Web.Config File : ASP.NET routing has to be enabled here.
2. Global.asax File : The Route table is created in the application Start event handler, of the Global.asax file.
How do you avoid XSS Vulnerabilities in ASP.NET MVC?
Use thesyntax in ASP.NET MVC instead of usingin .net framework 4.0.

What is the adavantage of using ASP.NET routing?
In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.

An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.

What are the 3 things that are needed to specify a route?
1. URL Pattern - You can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string.
2. Handler - The handler can be a physical file such as an .aspx file or a controllerclass.
3. Name for the Route - Name is optional.

Is the following route definition a valid route definition?
{controller}{action}/{id}
No, the above definition is not a valid route definition, because there is no literal value or delimiter between the placeholders. Therefore, routing cannot determine where to separate the value for the controller placeholder from the value for the action placeholder.

What is the use of the following default route?
{resource}.axd/{*pathInfo}
This route definition, prevent requests for the Web resource files such as WebResource.axd or ScriptResource.axd from being passed to a controller.

What is the difference between adding routes, to a webforms application and to an mvc application?
To add routes to a webforms application, we use MapPageRoute() method of the RouteCollection class, where as to add routes to an MVC application we use MapRoute() method.

How do you handle variable number of segments in a route definition?
Use a route with a catch-all parameter. An example is shown below. * is referred to as catch-all parameter.

controller/{action}/{*parametervalues}

What are the 2 ways of adding constraints to a route?
1. Use regular expressions
2. Use an object that implements IRouteConstraint interface

Give 2 examples for scenarios when routing is not applied?
1. A Physical File is Found that Matches the URL Pattern - This default behaviour can be overriden by setting the RouteExistingFiles property of the RouteCollection object to true.
2. Routing Is Explicitly Disabled for a URL Pattern - Use the RouteCollection.Ignore() method to prevent routing from handling certain requests.

What is the use of action filters in an MVC application?
Action Filters allow us to add pre-action and post-action behavior to controller action methods.

If I have multiple filters impleted, what is the order in which these filters get executed?
1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters
What are the different types of filters, in an asp.net mvc application?
1. Authorization filters
2. Action filters
3. Result filters
4. Exception filters

Give an example for Authorization filters in an asp.net mvc application?
1. RequireHttpsAttribute
2. AuthorizeAttribute

Which filter executes first in an asp.net mvc application?
Authorization filter

What are the levels at which filters can be applied in an asp.net mvc application?

1. Action Method
2. Controller
3. Application
[b]Is it possible to create a custom filter?[/b]
Yes

What filters are executed in the end?
Exception Filters

Is it possible to cancel filter execution?
Yes

What type of filter does OutputCacheAttribute class represents?
Result Filter

What are the 2 popular asp.net mvc view engines?
1. Razor
2. .aspx
What is difference between Viewbag and Viewdata in ASP.NET MVC?
The basic difference between ViewData and ViewBag is that in ViewData instead creating dynamic properties we use properties of Model to transport the Model data in View and in ViewBag we can create dynamic properties without using Model data.
What symbol would you use to denote, the start of a code block in razor views?
@

What symbol would you use to denote, the start of a code block in aspx views?
<%= %>

In razor syntax, what is the escape sequence character for @ symbol?
The escape sequence character for @ symbol, is another @ symbol

When using razor views, do you have to take any special steps to proctect your asp.net mvc application from cross site scripting (XSS) attacks?
No, by default content emitted using a @ block is automatically HTML encoded to protect from cross site scripting (XSS) attacks.

When using aspx view engine, to have a consistent look and feel, across all pages of the application, we can make use of asp.net master pages. What is asp.net master pages equivalent, when using razor views?
To have a consistent look and feel when using razor views, we can make use of layout pages. Layout pages, reside in the shared folder, and are named as _Layout.cshtml

What are sections?
Layout pages, can define sections, which can then be overriden by specific views making use of the layout. Defining and overriding sections is optional.

What are the file extensions for razor views?
1. .cshtml - If the programming lanugaue is C#
2. .vbhtml - If the programming lanugaue is VB

How do you specify comments using razor syntax?
Razor syntax makes use of @* to indicate the begining of a comment and *@ to indicate the end. An example is shown below.
What is Routing?
A route is a URL pattern that is mapped to a handler. The handler can be a physical file, such as an .aspx file in a Web Forms application. Routing module is responsible for mapping incoming browser requests to particular MVC controller actions.

Tuesday, July 17, 2012

Links on Latest Technology, Mgmt, Framework, and Useful stuff.

I studied the following stuff at my free time, hope it would be useful for you too..
.NET, WCF, AZURE interview questions
Design patterns, IOC, Aggregation vs Composition, etc.
Guide to understanding your Form-16
SQL Server - Shortcut Keys
Transactions, Nested Transactions, Exception handling - SET XACT_ABORT OFF
Cloud
Windows Azure Videos from Channel9
Agile Presentations
ASP.NET Dynamic controls data persisting
Health monitoring for ASP.NET applications
20 Subjects Every Software Engineer Should Know
LINQ - variable type inference, object initializers, anonymous types and lambda expressions
Six Considerations in moving your application to Cloud
Good example (using Music) to explain about cloud computing.
Multi-Tenancy Architecture Models
Agile - Kanban board
7 Reasons Why Your Team Does not Get to Done
Twisting the MVC Triad - Model View Presenter (MVP) Design Pattern
MVC - For beginner
MVC - Good explanation
Interview questions
C#.net Framework 4
Tuple:
  • Using Tuple we can return multiple values from a method.
  • Similarly Tuple we can pass multiple values to a method through a single parameter. 
SQL Server
- Joins (Inner Join, Outer Join, self join) definition with examples
Microsoft Press EBooks downloadable from
Singleton design pattern - 5 ways of implementation
WCF - Singleton WCF Proxy
WCF - Security
ASP.NET 2.0 PAGE LIFE CYCLE -  Events order - page, master page, user control, nested user control.
ASP.NET 2.0 Interview questions
MVC
The MVC pattern is a UI presentation pattern that focuses on separating the UI (View) from its business layer (Model). The pattern separates responsibilities across three components:
1. The view is responsible for rending UI elements,
2. The controller is responsible for responding to UI actions, and
3. The model is responsible for business behaviors and state management.
In most implementation all three components can directly interact with each other and in some implementations the controller is responsible for determining which view to display (Front Controller Pattern),
MVP
The MVP pattern is a UI presentation pattern based on the concepts of the MVC pattern. The pattern separates responsibilities across four components:
1. the view is responsible for rending UI elements,
2. the view interface is used to loosely couple the presenter from its view,
3. the presenter is responsible for interacting between the view/model, and
4. the model is responsible for business behaviors and state management.
In some implementations the presenter interacts with a service (controller) layer to retrieve/persist the model.
The view interface and service layer are commonly used to make writing unit tests for the presenter and the model easier.

.


Rhino Mocks - Mock Object Framework tools when performing Test-Driven Development


stub acts as a stand-in for a normal object. There are multiple reasons that you might create a stub. For example, as discussed above, the actual object might access an external resource such as a database or the file system causing the actual object to be too slow to use in a unit test. The stub enables you to perform a test in a reasonable amount of time without requiring any configuration.

IMPWhen performing state-based verification, the final statement in your unit test is typically an assert statement that asserts that some condition is  true.
When performing behavior verification, your test typically does not end with an assert statement. Instead, the interaction of the objects being tested is verified. Rhino Mocks throws an exception automatically when mock expectations do not meet reality.
TDD - Test Driven Development

How Facebook works?

Project Management


Project management is about taking ideas and converting them into a planned, resourced and funded project. The project management process can be broken down in to three stages: Project Initiation, Project Control and Project Closure. 

During the project initiation stage it is necessary to clearly and explicitly define what the project is intended to achieve and its scope. By defining this first, you set a benchmark for the quality of what is actually produced at the end of the project. You also determine what resources and time will be allotted to complete the project.

The project control stage is about monitoring and controlling the progress of the project. It's also about controlling the quality of the product by tracking progress through regular checkpoints and resolving issues that arise during the course of the project. The majority of the work and time spent on a project is during this stage.

The purpose of the project closure stage consists of two parts: formally closing the project and passing on any lessons that can be applied to other projects. There may be some outstanding work that needs to be done and a plan for those things should be done in this stage. There is no need to reinvent the wheel every time you do a project but you do want to become more efficient.
You will have learned how to carry out this type of project better in the future, and will have a better idea of how long the various activities on this type of project will take to do. Any information or documentation from the project should be filed away for future use.

ASP.NET Basics


  1. What is an interface and what is an abstract class?
    In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.
  2. Session state vs. View state:
    In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:
    • Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.
    • Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.
    • Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.
  3. Can two different programming languages be mixed in a single ASPX file?
    ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.
  4. Is it possible to see the code that ASP.NET generates from an ASPX file?
    By enabling debugging using a <%@ Page Debug="true" %> directive in the ASPX file or a  statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files).
  5. Can a custom .NET data type be used in a Web form?
    This can be achieved by placing the DLL containing the custom data type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.
  6. List the event handlers that can be included in Global.asax?
    • Application start and end event handlers
    • Session start and end event handlers
    • Per-request event handlers
    • Non-deterministic event handlers
  7. Can the view state be protected from tampering?
    This can be achieved by including an @ Page directive with an EnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the  statement in the Web.config file.
  8. Can the view state be encrypted?
    The view state can be encrypted by setting EnableViewStateMac to true and either modifying the element in Machine.config to When during the page processing cycle is ViewState available?
    The view state is available after the Init() and before the Render() methods are called during Page load.
  9. Do Web controls support Cascading Style Sheets?
    All Web controls inherit a property named CssClass from the base classSystem.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.
  10. What namespaces are imported by default in ASPX files?
    The following namespaces are imported by default. Other namespaces must be imported manually using @ Import directives.
    • System
    • System.Collections
    • System.Collections.Specialized
    • System.Configuration
    • System.Text
    • System.Text.RegularExpressions
    • System.Web
    • System.Web.Caching
    • System.Web.Security
    • System.Web.SessionState
    • System.Web.UI
    • System.Web.UI.HtmlControls
    • System.Web.UI.WebControls
  11. What classes are needed to send e-mail from an ASP.NET application?
    The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application.MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's System.Web.Mailnamespace.
  12. Why do some web service classes derive from System.Web.WebServices while others do not?
    Those Web Service classes which employ objects like ApplicationSessionContextServer, and Userhave to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.
  13. What are VSDISCO files?
    VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.
  14. How can files be uploaded to Web pages in ASP.NET?
    This can be done by using the HtmlInputFile class to declare an instance of an  tag. Then, a byte[] can be declared to read in the data from the input file. This can then be sent to the server.
  15. How do I create an ASPX page that periodically refreshes itself?
    The following META tag can be used as a trigger to automatically refresh the page every n seconds:
    <meta http-equiv="Refresh" content="nn">
  16. How do I initialize a TextBox whose TextMode is "password", with a password?
    The TextBox’s Text property cannot be used to assign a value to a password field. Instead, its Value field can be used for that purpose.
    <asp:TextBox Value="imbatman" TextMode="Password" 
                          ID="Password" RunAt="server" />
  17. Why does the control's PostedFile property always show null when using HtmlInputFile control to upload files to a Web server?
    This occurs when an enctype="multipart/form-data" attribute is missing in the 
     tag.
  18. How can the focus be set to a specific control when a Web form loads?
    This can be achieved by using client-side script:
    document.forms[0].TextBox1.focus ()
    The above code will set the focus to a TextBox named TextBox1 when the page loads.
  19. How does System.Web.UI.Page's IsPostBack property work?
    IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a__VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.
  20. What is WSDL?
    WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org)
  21. What is UDDI?
    UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.
  22. Is it possible to generate the source code for an ASP.NET Web service from a WSDL?
    The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.
    Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.
  23. Why do uploads fail while using an ASP.NET file upload control to upload large files?
    ASP.NET limits the size of file uploads for security purposes. The default size is 4 MB. This can be changed by modifying the maxRequestLength attribute of Machine.config's  element.
  24. Describe the difference between inline and code behind.
    Inline code is written along side the HTML in a page. Code-behind is code written in a separate file and referenced by the .aspx page.