#5 :Action Selectors(ActionName)in MVC

ActionName :

You can customize ActionName in a Controller via ActionName Attribute class.


[ActionName("Find")]
public ActionResult Search(MyModel model)
{
return Content("Hello"+model.Name+model.id);
}

In the Above Method we can only reach the Search Action from Controller via an Action Name Find and not by Search.

#3 Passing Parameters to Action

We can define parameters that has to be passed to Action Methods in MapRouteMethod,


routes.MapRoute(
"Search",
"{controller}/{name}/{id}",
new{ controller = "Search",action ="Cusine", name = "",id=0}
);

In the above example we define two parameters name and id to the action method Cusine. 

To pass complex object we need to pass each property in the URL,this will get mapped to corresponding model in Action Method:


routes.MapRoute(
"Search",
"{controller}/{name}/{id}",
new{ controller = "Search",action ="Cusine", name = "",id=0}
);

---Action Method

public ActionResult Cusine(MyModel model)
{
return Content("Hello"+model.Name+model.id);
}

public class MyModel
{
public String Name { get; set; }
public int id { get; set; }
}


	

#2 Customize URL in MVC

you can customize Request URL in Route.Config.


routes.MapRoute(
 "Search",
 "{controller}/{name}",
 new{ controller = "Process",action ="Find", name = ""} 
 );

In the above example Search is the URL Route Request  which gets mapped to Controller of Process with an Action Method Find which accepts name as parameter (Request URL and Controller name can be different)

1.The Routing Request url can be of any name,it need not match with controller , but you must define the corresponding controller with its action in the MapRoute Method. 

2.There is no mandatory rule that the URL should be of {Controller}/{action},it can be simply {Controller} and again you must define the respective controller with action in MapRoute.

 


	

MVC-Model View Controller

All Incoming Request to application is handled by Controller. The controller decides respective Model  and View.

Capture

for instance,if a request is made with URL “www.site.com/Home /About” ,then  following happens

1.Find Controller with name Home.

2. Find a Method named About in controller  which returns the respective View(View pulls data that has to be displayed from Model).

To summarize :

1.Model takes care of DataAcesss stuffs.

2.View takes care all of UI Components.

3.Controller maps the View and Model.

 

 

 

 

 

#67: WCF Basics

WCF

WCF Services that are exposed to clients are through Endpoints.Endpoints forms the base while exposing service to clients.A Service can include one or more endpoints.

Endpoints Consists of three basic Components:

1.Address : Where is the service located ?

2.Binding: Protocol used to communicate with service (http,tcp etc..)

3.Contract:Contracts(Interface/Method definition) that has to be  exposed  to clients. Consumers/Clients uses this Contract to generate proxy.

#66:Service in WCF

A service is CLR type that exposes business functionality to Clients.In order to expose the Functionality as service,

1.The class/Interface  must be decorated by ServiceContractAttribute.

2.The Methods(functions inside class) exposed through Service must be decorated with OperationContractAttribute


[ServiceContract] //service contract
interface IHelloindigoService
{
[OperationContract] //method exposed via service with oepration contract annotaion
string HelloService();
}

#65 Clustered Vs Non-Clustered Index

Need: Data/Records are Stored in heap,they are generally put up in the next available space over heap without any arrangement(Sorting).This kind of strategy is good when every time data is inserted,but when a selection over data is made on heap,we would encounter performance barrier and our selection query would be too slow because of our arrangement of Data over heap. Indexing provides a solution by defining an arrangement of records over heap.

Types:

1.Clustered Index :Only one Per Table and Uses B-Tree where each leaf node points to data in heap.They are sorted and B-Tree Structure Changes every time when an insertion is made.

2.Non-Clustered Index(NCI):There can be one or more NCI per Table and their leaf node does not point to data but instead point to address/Location.

#64 ViewData and ViewBag

They are responsible for passing data from controller to view.

ViewData:

1.It is a dictionary,which holds keys as strings.

2.It can be used to store any complex data.

3.They have to casted/Null check has to be made in view to avoid Error.

ViewBag:

1.They use dynamic property listed with C#4.0

2.They do not require type casting of complex objects.


/*Controller*/

public ActionResult Index()
{
ViewData["Sample"] = "Sample ViewData";
ViewBag.Hello = "Sample ViewBag";
return View();
}

They are accessed in view with respective Name declared in controller

/*View*/

@ViewBag.Hello
@ViewData["Sample"]