Wednesday 20 May 2015

How to Install IIS 8 on Windows 8

Here we will learn how to install IIS server in window 8 for this there are some steps for this installing this.
1.   Go to Start menu and press CTRL+R and that window you type “appwiz.cpl”  click OK then you will see installation screen

2.   Means this will open features or installation part of control panel  of this screen in the left side you will see some links  and click on the “Turn Windows features on or off” link.


3.   When you will click on this link Windows features on or off screen will open from there you select “Internet information Service” check box


4.   When you will expand this you will see subcomponent you will see that it install all the things which we are needed for hosting a service.


5.   Here you will click on OK it will install this


6.   After this it will install so now again Go to Control panel -> Administrative Tools - > search for Internet Information Services (IIS) Manager

Now you will see this IIS Server.

Page life cycle in MVC in asp.net

Here we will learn Asp.net MVC life cycle.
Asp.net MVC Life Cycle totally different with web application life cycle, In asp.net MVC does not contain any event alike web form contain ex.pre Render, oninit etc.
Here whenever we put request for a URL the only thing which happen here is that some controller action is called and response render to the browser.
Asp.Net MVC Life Cycle :
The following diagram shown the MVC life cycle.


1.   Routing:
          Routing in MVC is nothing but matching incoming request (URI) with action. The mvc request is work on basis of the routing data which exists in Route Table. At the first time request is empty means first request of the application route table is empty. Application start event fill the required routes depending on the  URL which is used by the client browser “UrlRoutingModule” uses route table to retrieve correct data of route table for defining which controller and action should accureS.

1.   If UrlRoutingModule gets correct RouteData, it creates RequestContext object which represent current HttpContext and RouteData. Routing engine forwards the RequestContext object to corresponding IRouteHandler
If UrlRoutingModule does not get matching controller and its action for incoming request it returns HTTP status code 404 (Page not found).
Below example shows how you can create mapping of routes in RegisterRoutes method called from Application Start Event.
public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        "Default"
        , "{controller}/{action}/{id}"
        , new { controller = "Security",
                action = "Login", id = UrlParameter.Optional }               
    );
}
           
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); specifies any request for .axd should be ignored and should not process.
routes.Maproute specifies route name as default and matching request should be forward toSecurity controller and Login method.
For each mapping Route name should be unique. You can remove particular route byRouteTable.Routes.Remove(“route item”) method. See more about ASP.NET MVC routing with example

2.   IRouteHandler Interface
It exposes a single method GetHttpHandler, which provides RouteHandler class instance based on RouteContext data to process request. All Routes which are added to RouteTable by MapRoute extension method are handled by default RouteHandler that is MvcRouteHandler class defined in the System.Web.Mvc namespace.
Below is interface definition
public interface IRouteHandler
{
    IHttpHandler GetHttpHandler(RequestContext requestContext);
}           
           
3.   MVCHandler
MvcHandler is responsible for initiate actual processing of ongoing request and generate response. MvcHandler gets information of current request through RequestContext object passed to its constructor.
Below is the constructor code for MVChandler
public MvcHandler(RequestContext requestContext)
{
}
           
MvcHandler class implements three interfaces : IHttpAsyncHandler, IHttpHandler and IRequiresSessionState. IHTTPHandler's ProcessRequest method actually process the ongoing request.
The ProcessRequest method is implemented in MvcHandler as below
protected internal virtual
         void ProcessRequest(HttpContextBase httpContext)
{
    SecurityUtil.ProcessInApplicationTrust(delegate {
        IController controller;
        IControllerFactory factory;
        this.ProcessRequestInit(httpContext, out controller, out factory);
        try
        {
            controller.Execute(this.RequestContext);
        }
        finally
        {
            factory.ReleaseController(controller);
        }
        });
}

           
4.   The Controller Executes
MvcHandler uses IControllerFactory instance and to get IController object. All Mvc controllers implement IController interface. This interface has Execute method which actually execute your action method code. So Mvc Controller executes method from IController interface.
At the beginning of Execute method it creates TempData object. The Execute method get Action from RouteData based on ongoing request. Then MVC Controller callControllerActionInvoker which creates a list of parameters coming with URL. These parameters are collected from request objects Parameters collection. This parameter list will be passed to Controller Action method.
Finally it calls InvokeAction method to execute action.
5.   Action Execution
After the particular controller gets instantiated ActionInvoker determines which specific Action method needs to be execute. ActionInvoker uses ActionNameSelectorAttribute and ActionMethodSelectorAttribute to select Action method for execution. Action method always returns ActionResult.
If you do not want any specific method should not accessible through public URI, you can mark that method with [NonAction] attribute.
6.   ViewEngine
If ActionResult returns a ViewResult, execution pipeline selects appropriate ViewEngine to render ViewResult. It is taken care by view engine's interface IviewEngine. ASP.NET MVC has Webform and Razor view engines. You can use any of them to develop Views. You can also create your own ViewEngines and use it. For performance reason it is better to remove ViewEngines which are not required. Below code clear all ViewEnginees and register only Razor
protected void Application_Start()
{
    //Remove All Engine
    ViewEngines.Engines.Clear();

    //Add Razor Engine
    ViewEngines.Engines.Add(new RazorViewEngine());
}
 
7.   Render View Result
Action method can return a simple string value, binary file, JSON data or JavaScript block. And the most important is ViewResult. It returns response in form of HTML which can be rendered to browser using ViewEngine.
Action method get required or optional user input as part of URL. Then it executes the code and prepare response for current request.
For each Action method controller executes either RedirectToAction or RenderViewmethod. The RenderView method uses a class named ViewLocator to find corresponding View to render.
Then If there is MasterPage or ViewData then it get set appropriately and finally the RenderView method get called on ViewPage.
In Short we will learn page life cycle:
Basically, there is no page life cycle per se (because there is no 'page' object), but there is a request processing pipeline, which usually goes something like this:
1.   Incoming request is picked up by the System.Web.Routing.UrlRoutingModule which uses the request url to map the request to a controller action method.
2.   The appropriate controller is instantiated
3.   The OnActionExecuting-methods of action filters on the controller and/or action are invoked
4.   Model binding and input validation may occur
5.   The action method itself is invoked
6.   Any OnActionExecuted and OnResultExecuting-methods of action filters are invoked
7.   The ActionResult returned by the action method (typically, a ViewResult which renders HTML) is executed.
8.   Any OnResultExecuted-methods of action filters are invoked.

What Is MVC in Asp.Net

In This tutorial we will learn about the MVC (Modal View Controller ) in ASP.Net . MVC  is a framework which is used to make a web application using Modal view controller design.
MVC Means Modal View Controller , Here “Modal” represent database instance means database fields objects.
View display the data to the end user (from database), “Controller” handle all the database operation or all the inputs
Modal
1:-  A Modal is a class that contain {Get  Set}  properties of database fields.
2:- A modal class is accessible by controller and view.
3:- Modal can be used to transfer the data from Controller to view
4:- View is used for modal to display the data.
View
1:- Basically View is used to display the data or  it is ASPX page without code behind file.
2:- All the design part , formatting ,HTML code can be write inside view.
3:- In MVC For showing View or design part we have to write code in controller.
Controller
1:-Controller use modal class for passing the data.
2:-Controller use ViewData for passing the data to view or we can say for passing the data to end user.
3  System.Web.Mvc" Namespace is used for the MVC Design framework. it is a standard design pattern.
4  when you creat a MVC application , remember that MVC application does't replace web forms, So we can use either framework or a  web application.

5  MVC design pattern is


Advantages of  MVC  application
1-  This make a web application easier to handle complexity using dividing  an application into 3 parts like Modal,View,Controller.
2-  This MVC does not use  the server-based forms or View state. It  make MVC framework  pure or ideal for developers who want full control on an application.
4-  It gives support to test-driven development(TDD). For getting  information about  this then Go to this link  is http://agiledata.org/essays/tdd.html
5-  Asp.Net MVC is used  for web application which  is used by Big team of developers   and that development team want  good control over the web application.

Advantages of  Web Form  based web application
1- Web Form supports event modal That stores on HTTP, which give benefit for line-of business  development .
2-  This type of application provide us a lot of events those are supported  in many  sever controls.
3-  Web Form uses a page  controller  type of pattern, this add functionality to the  individual pages.
4- It is very useful for small team of development those want  many type of components for development.
5-  It  is  complex  because of the components (due to page class, modal, data) are totally integrated.
The main advantages of ASP.net MVC are:
1.     It gives the full control on the rendered HTML.
2.     It Provides us to clean separation- of- concerns(SoC).
3.     Enables also Test Driven Development (TDD).
4.     Easy to  integration with JavaScript frameworks.
5.     It Follow the design of stateless nature of the web.
6.     REST ful urls that enables SEO.
7.     There is No ViewState and PostBack events
The main advantage of ASP.net Web Form are:
1.     It provides RAD development
2.     Easy development for developers those are coming from window form development.

Features of MVC4  framework
1.   Asp.net Web API
·         It is a new framework for making  HTTP services.
·         This can reach wide range of clients, with including mobile devices and browsers.
·         It is an good  platform for making RESTful Services.

2.   Enhancements in default template

·         The default template that is used to create new ASP.NET MVC4 projected has been updated  for  more attractive.

·      ·         A Template employs a technique called Responsive Design to look better in browser and mobile application.

3.   Display Modes
·                     select an application  views depending on the browser that's making the request

For example :

·                     If a desktop browser requests for the  Home page, and the application use theViews\Home\Index.cshtml template.
·                     If a mobile browser requests for the Home page, the application use theViews\Home\Index.mobile.cshtml template.


Main focus of Asp.net MVC4 : This making it easier to making a mobile web application  Other than mobile web applications its focus is on better HTML5 support and making it  AS.P.net MVC web application cloud ready. We also can use development web applications which will work better across for different mobile devices and desktop web browser.
       ASP.NET Web API : It is a framework for building and consuming HTTP Services. It also support wide range of clients including browser and mobile devices. It is a nice  platform for Making a  RESTful Services since it talks HTTP.

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...