KnockOut Subscribe to an Event

KnockOut Subscribe:- From the term itself, it is clearly understood that this is used for subscribing to something. This can be helpful in situations where you need to communicate between multiple view models

KO subscribe makes your task for passing data from one view model to another very simple and faster. It helps to inform other view models that the value for a particular KO observable has changed.

class MemberViewModel{
 this.detailVm= ko.observable(null);
 this.detailVm.memberId.subscribe(function (value: number) {
alert("value changed");
});
}
detailVm:KnockoutObservable<DetailViewModel>;

class DetailViewModel{
 this.memberId= ko.observable('');
}
memberId: KnockoutObservable<number>;


ASP.NET MVC 5 With ReactJS

react2

Introduction

React is a very popular front-end library developed by Facebook. It’s basically used for handling View layer for web and mobile apps. The biggest advantage of React JS is that it allows us to create reusable UI components. There are many popular JavaScript libraries in the market but React is the the most popular, and it has strong and large foundation and community behind it.

When we develop applications in MVC, we use JavaScript, jQuery, and HTML with it. Now, NuGet package team has provided in-built library package for Visual Studio for MVC 4, 5 and ASP.NET Core.

So now, you can directly download the NuGet Package for React.js for your MVC application from npm, and use it in your application easily.

Let’s start with a demo.

  • Create New Project  -> File >> New >> Project.
  • Select “NET Framework 4.6.2” and Templates >> Visual C# >> Web >> ASP.NET Web Application. Call it OshinReactDemo.

OshinReact1

  • Now, in the “New ASP.NET Web Application” dialog, select Empty Template. I always recommend you use this template for new sites, as others include large amounts of unnecessary packages that may not even work for you.OshinReact2
  • Now, install React JS to newly created .NET project.
  • Right click on your project in the Solution Explorer.
  • Select “Manage Nuget Packages”.
  • Search For “ReactJS.NET” and install the Web.Mvc4 package.OshinReact3
  • Go to Solution Explorer, right click on the Controller folder, and click Add >> Controller.image004
  • Name the Controller as “HomeController” and select “Empty MVC Controller” as your template.image005
  • Now, once the Controller has been created, right-click on Return View() and click “AddView”.
  • In the AddView Dialog, fill the following details.
  • View name: Index
  • Create a strongly-typed View: Unticked
  • Create as a partial view: Unticked
  • Use a layout or master page: Untickedimage006
  • Now, replace the content of new view file with the below code.code1

 

  • Now, we need to create the JavaScript file (OshinReact.jsx). Right click on your project and select Add >> New Folder, enter “Scripts” as folder name.
  • Right click on Folder and select Add >> New Item.
  • Select Web >> JSX File, and enter “OshinReact.jsx” as file name. Then, click “Add”.OshinReact4.png
  • React is all about modular, composable components, and basically it has a component structure.
  • Now, we will build CommentBox Component , which is just a simple.
  • Add the below code to OshinReact.jsx.code2

 

  • Run your application.You can see “Hello, world! This is Bernaditta Oshin Hogan.” in your browser.

OshinReact5

For more information please visit  https://reactjs.net/

Thank You!!!!

Project documentation with DOXYGEN

Doxygen is the standard tool for generating documentation from annotated C++ sources, but it also supports other popular programming languages such as C, Objective-C, C#, PHP, Java, Python, IDL (Corba, Microsoft, and UNO/OpenOffice flavors), Fortran, VHDL, Tcl, and to some extent D.

Doxygen can help you in three ways:

  1. It can generate an on-line documentation browser (in HTML) and/or an off-line reference manual from a set of documented source files. It also support for generating output in RTF (MS-Word), PostScript, hyperlinked PDF, compressed HTML, and Unix man pages. The documentation is extracted directly from the sources, which makes it much easier to keep the documentation consistent with the source code.
  2. We can configure doxygen to extract the code structure from undocumented source files. This is very useful to quickly find our way in large source distributions.
  3. Doxygen can also visualize the relations between the various elements by means of include dependency graphs, inheritance diagrams, and collaboration diagrams, which are all generated automatically.

Doxygen is developed under Mac OS X and Linux, but is set-up to be highly portable.It runs on most other Unix flavors as well, executables for Windows are available.

Step 1.

Install doxygen in your machine.We can get the link from the site.Here i have used this

doxygen-1.8.13-setup.exe.

Step2: Create a folder for saving the documents .

Step3: Keep your source code ready.

Step4:Execute doxygen.

After installation select Doxywizard .

Doxygen_1

Open doxywizard.

Doxygen_2

In this we can specify the path of doxygen by selecting  the bin folder of doxygen.

In the project name field you can type the name which you want to display in documentation,also insert logo,source code directory,destination directory etc.

Dox_4

Then in the mode you need to select the source code type.Here i have selected C#.

Dox_5

And in the output we can select multiple options .

Dox_6

Also we can add diagrams in report using the diagrams tab.

Dox_7

Now we can run the doxygen.It will generate the document.

Dox_8After completing the execution we can check the output using the link -Show HTML output.

Dox_9.png

It will looks like this.

Dox_10

If we have added any comments in the program it will display here.

In this I have added some comments in one of the function in the controller.

Dox_11

Dox_12

Also we can get the word document generated by the doxygen .This will be saved in the selected destination folder.

Dox_14

Let’s see the output.

Dox_13

For more information please visit  http://www.doxygen.org/

Thank You!!!!

MVC – ASP. NET

The following topics are covered in this article:

  1. M-V-C
  2. How a request is processed?
  3. Folder Structure and Naming Conventions
  4. Why MVC?

M-V-C

MVC is Model-View-Controller, a design pattern used in web development. If you are familiar with Web Forms in ASP.NET, you may trace back a few concepts in here with what you already know and if you are not, then let’s see what MVC is. Unlike Web Forms which has the aspx and aspx.cs file with server controls and code-behind concepts, here in MVC everything circles around classes and HTML. No server-side controls or no drag and drop of controls are possible in the MVC world.

Controller

The controller is a class which holds the action methods. It mainly controls the flow of the application. The controller does the processing of the request made by the user by making the database calls or do any other ‘job’ to process the user’s request and returns the view. The controllers should be inherited from the ‘Controller’ class.

An example of the controller is as follows:

Controller

Here Index() is the action method defined in the Speaker controller. The return type should be ActionResult or any classes inherited from ActionResult. Possible other options include the following:

a. FileResult

b.JsonResult

c. ViewResult

Model

The model is a class which holds the data. The data is described as properties in Models.

ModelClassno

In the above Speaker model, SpeakerId and Name are the properties defined.

The model can also hold some optional attributes which act as decorations to the data for validation. These attributes are called Data Annotations. The data annotations handle the client side as well as server-side validation without writing any additional code.

Fotor_150601377685191

Model with Data Annotations

In the above sample code, [Required] is the attribute that specifies that the value is required for the properties Name and Description. Hence the required field validator is implemented by the data annotation [Required] without any extra coding.

View

The view is the HTML content which will be shown to the user. When a request is processed, the view is returned by the controller.

How the request is served?

Fotor_150591210368372

In the case of MVC application when a URL is requested by the user, the Global.ascx file with the help of the class RouteConfig.cs executes the corresponding action results in the controller. In fact, when a web request happens a method in the controller class is called. The Controller ‘does something’ and sends the Model (data) to the View (UI) and the response goes out to the user. Here the controller can either make a database call, do some other processing or anything it wants to and the result of which will be the data (Model) to be shown to the user (View). In fact, if there is no data to be sent to the view, it can just call the view without the Model. And it’s absolutely fine.

Consider the sample URL below:

http://mysite/Speaker/Index

Here, ‘Speaker’ is the controller name and ‘Index’ is the name of a method inside the SpeakerController.cs class.

So when the user requests this URL in the address bar of the browser, the action method ‘Index’ inside the SpeakerController.cs class is executed and a view with the name ‘Index’ which has the HTML content is returned back.

Routing

The routing rules are defined in the file RouteConfig.cs. When the request comes in, the Application_Start event in the Global.ascx file invokes the routing rules defined in the RouteConfig class. A default route will be defined in it and we may add more routes as and when needed. The RouteConfig.cs appears under the folder App_Start by default, but it is not mandatory for the file to be in that location itself for the application to run.

ROuteConfigFolder

RouteConfig.cs

The sample code which is in the RouteConfig.cs class is as follows:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
       routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

       routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        ); 
    }
}

The line url: “{controller}/{action}/{id}” specifies the pattern of the url. Here id is the optional parameter passed to the action.

defaults: new { controller = “Home”, action = “Index”, id = UrlParameter.Optional } :This specifies the default controller and action name.

Folder Structure and Naming Conventions

For MVC to work properly, one has to follow a handful of naming conventions and folder structures.

Controllers: The controllers are to be placed inside the ‘Controller’ folder. All the controllers are to be named ‘Controller’ after the actual name. If you need to create a Home controller, then it should be named HomeController.cs.

Fotor_150600816358070

Controllers Folder Structure

View: All the views reside in the ‘Views’ folder. For the application to work correctly, inside the ‘Views’ folder, there should be a folder with the name of the controller, and the view with the name of the action method defined in the controller should be there in this folder.

If we have an action ‘Index’ inside the SpeakerController, then corresponding to that, there should be a view with the name Index.cshtml (for C#. For VB, it is Index.vbhtml) inside the folder Speaker of the Views folder.

Fotor_150600790070440

Views Folder Structure

Model: In the case of the model, it’s NOT mandatory to have the model inside the model folder or even inside the application. The model can be placed anywhere in the application or if you would like to use models from an external source, that is also possible. Having said that, normally if the models are in the same application itself then it is preferable to have them inside the Model folder in so that everything will be in an organized fashion.

Why MVC?

The biggest advantage of MVC over Web Forms is the separation of concern. In the case of Web Forms, the controls in the page and the code on which it executes are tightly coupled. If there is a button Button1 on the aspx page, there is an event Button1_OnClicked in the aspx.cs file which is tightly coupled to the button click. In the case of MVC, the UI, and the business logic is separated and is defined across the Model, View, and Controller and hence the dependency is minimized.

Another advantage of MVC is testability. Since the controller is a class, every method in that is unit testable unlike the case of web forms. It enhances the application in the long run in such a way that if there is any change in any of the code in the future, it can be unit tested which saves time and energy.

Hope to see you soon on another topic! Happy coding!

 

 

Set up Angular 2 in Visual Studio 2017

Angular is a platform that makes it easy to build an application in the web. Angular turns your template into codes that are highly optimized for Javascript. It quickly creates UI views with simple and powerful template syntax. Here we will be discussing on how to set up Angualr 2 in Visual Studio.

In order to install the Angular 2 the first thing we need is to install Node.js. This can be installed from the following link  https://nodejs.org/en/download/ .We can choose 32-bit or 64-bit according to our system configuration.

NodeJs.PNG

We can check if it is already installed checking the version of node.js in the command prompt.

NodeVersion.PNG

If it is not installed we will be getting an error message saying node is not recognized as an internal or external command. Next step is to create a new project in visual studio.Then we have to configure the environment settings for node and npm.ExternalTools.PNG

This tells Visual Studio to look for external tools (like npm) in the global path before the internal path.

The next thing we have to do is install typescript for visual studio. Typescript is designed for development of large applications and trans-compiles to JavaScript.

Now we have to download the Quick Start Files  from the Angular web site using the link below.
Angular QuickStart.PNG

Extract the contents of the downloaded .ZIP folder. https://github.com/angular/quickstart

Copy the required files from the unzipped folder which includes

  • src
  • bs-config.json
  • package.json
  • tslint.json

SelectedFiles.PNG

Copy the above folders and files into the solution and include it in the project.Then we have to restore the packages. In order to do that we have to right click the package.json file and then click the Restore Packages

Restore Packages.PNG

This will result in the installation of all the node_modules.You can check the output window to find out whether it has been restored correctly or not.

NodeModules.PNG

We don’t have to include the node modules in the project.Now the installation is completed and we can run the project using npm start but not through visual studio. In order to start the project with visual studio we need some more configurations to do. Notice that in the browser when we clicking F12 we have 404 not found errors for the following sites

  • styles.css
  • systemjs.config.js
  • main.js

All these files are present in “src” folder. So to fix these “404 Not Found” errors, in index.html file, change <base href=”/”> to <base href=”/src/”>

IndexFile.PNG

and we have to include “/” before node_modules

At this point reload the page and you will see “Hello Angular” message without any errors.

If you want Visual Studio to compile Typescript to JavaScript when the changes are saved, we need to turn this feature “ON” by including the following setting in tsconfig.json file

ComplieOnSave.PNG

Happy coding 🙂

 

 

 

JsGrid

JsGrid is a clientside data grid control.It supports basic grid operations like inserting, editing, deleting, paging, and sorting. It is based on Jquery. Here I would like to explain how we can create a jsGrid and bind data to it.

First thing is to include the jQuery library and the jQuery  jsgrid  plugin’s. Cdnjs is the following:

//cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.js

Next Step is creation of JsGrid. For that create an empty div in your webpage.

<div id="jsGrid"></div>

Next step is to call the JsGrid plugin to render the data gird into div.

We can write function as follows:

</pre>
var sampleGrid = {

'config': {

},
'init': function (config) {
if (config && typeof (config) === 'object') {
$.extend(sampleGrid.config, config);
}
sampleGrid.createGrid();
},
createGrid: function () {
$(".rptpagesize").show();
$("#jsGrid").jsGrid("destroy");

$("#jsGrid").jsGrid({
width: "100%",
pageLoading: true,
paging: true,
autoload: true,
noDataContent: "No Record Found",
pageSize: 15,
pagerContainer: "#externalPager",
pagerFormat: "Pages: {first} {prev} {pages} {next} {last} &nbsp;&nbsp; {pageIndex} of {pageCount}",
data: [
{
Name: "Ada Lovelace",
Age: 36,
Address: "kk",
Country: "ll",

},
{ Name: "Grace Hopper",
Age: 85,
Address: "sampleAddress",
Country: "France",}],

fields: [
{ name: "Name", type: "text", width: 150 },
{ name: "Age", type: "number", width: 50 },
{ name: "Address", type: "text", width: 200 },
{ name: "Country", type: "text", width:30 },

]
});

return false;
}
}
<pre>

Fields

Here fields represents the grid headers.Each field has general options and specific options depending on field type.

Data

An array of items to be displayed in the grid. The option should be used to provide static data.

For non static data we can use the controller.Here is an Example


$("#jsGrid").jsGrid({
width: "100%",
pageLoading: true,
paging: true,
autoload: true,
noDataContent: "No Record Found",
pageSize: 20,
pagerContainer: "#externalPager",
pagerFormat: "Pages: {first} {prev} {pages} {next} {last} &nbsp;&nbsp; {pageIndex} of {pageCount}",

controller: {
loadData: function (filter) {
var d1 = $.Deferred();

var a = {
pageIndex: filter.pageIndex,
pageSize: filter.pageSize,
classId: classId
}
$.ajax({
url: "/uiservice/GetCurrentData",
dataType: "json",
data: JSON.stringify(a),
contentType: "application/json; charset=utf-8",
type: "POST",
}).done(function (response) {
d1.resolve(jQuery.parseJSON(response.d));
});

return d1.promise();
},
},
// determine the columns
fields: [
{ title: "Student", name: "Name", type: "text" },
{ title: "School", name: "SchoolName", type: "text", width: 50, align: "center"},
{ title: "Standard", name: "Standard", type: "text", width: 50, align: "center" },
{ title: "Grade", name: "Percentage", type: "number", width: 50 },
]
});

We can do sorting,pagination,edit using JsGrid.

For more information You can refer the following:

http://js-grid.com/docs;

Thank you!!

 

 

WannaCry Ransomeware Protection

How it works:
WannaCry is a form of ransomware that locks up files on your computer and encrypts them in a way that you cannot access them anymore. It targets Microsoft’s widely used Windows operating system.
When a system is infected, a pop-up window appears with instructions on how to pay a ransom amount of $300.
The pop-up also features two countdown clocks; one showing a three-day deadline before the ransom amount doubles to $600; another showing a deadline of when the target will lose its data forever. Payment is only accepted in bitcoin.
The ransomware’s name is WCry, but analysts are also using variants such as WannaCry.

How it spreads:
Ransomware is a programme that gets into your computer, either by clicking or downloading malicious files. It then holds your data as ransom.
Some security researchers say the infections in the case of WannaCry seem to be deployed via a worm, spreading by itself within a network rather than relying on humans to spread it by clicking on an infected attachment.
The programme encrypts your files and demands payment in order to regain access. Security experts warn there is no guarantee that access will be granted after payment.
Some forms of ransomware execute programmes that can lock your computer entirely, only showing a message to make payment in order to log in again. Others create pop-ups that are difficult or impossible to close, rendering the machine difficult or impossible to use.

What can you do to prevent infection:
Here are the steps you should take to protect yourself against ransomware:
– Install and use an up-to-date anti-virus solution (such as Microsoft Security Essentials)
– Make sure your windows software is up-to-date
– Avoid clicking on links or opening attachments or emails from people you don’t know or companies you don’t do business with
– Ensure you have smart screen (in Internet Explorer) turned on, which helps identify reported phishing and malware websites and helps you make informed decisions about downloads
– Have a pop-up blocker running on your web browser
– Regularly backup your important files
– Be wary of visiting unsafe or unreliable sites.
– Never click on a link that you do not trust on a web page or access to Facebook or messaging applications such as Whatsapp and other applications.
– If you receive a message from your friend with a link, ask him before opening the link to confirm, (infected machines send random messages with links).
– Be aware of fraudulent e-mail messages that use names similar to popular services such as PayePal instead of PayPal or use popular service names without commas or excessive characters.

Ensure you have applied the windows fix given at Microsoft documentation @ https://technet.microsoft.com/en-us/library/security/ms17-010.aspx

Create charts using ChartJs

The JavaScript library Chart.js is an open source project created by Nick Downie in 2013.

ChartJS is a library-based on javascript and HTML5. The main foundation of this library is <canvas> element in HTML5.

A great way to get started with charts is with ChartJs, a JavaScript plugin that uses HTML5’s canvas element to draw the graph onto the page. It’s a well documented plugin that makes using all kinds of bar charts, line charts, pie charts etc.

ChartJS is a powerful, dependency free JavaScript library which builds graphs via the canvas element.

The great things about ChartJs are that it’s simple to use and really very flexible.

Here I want to share the steps to display a barchart in my MVC application.The value of chart will vary based on the provider and date  filter.

ChartJS uses the canvas element. The basic pattern is to create the canvas element in HTML, select it with JavaScript, and create the Chart while passing in the data the chart is built from.

We can customize the ChartJs library to create whatever chart you visualize. The library provides six basic designs by default.

  • Line: Show your data as the peaks and valleys of a line graph.
  • Bar: Demonstrate trends with many different shaped bars.
  • Radar: Present data just like your local meteorologist.
  • Pie: Present data as slices of the overall circle.
  • Polar area: It’s easier to quote the documentation on this chart as it is similar to pie charts. The variable isn’t the circumference of the segment, but the radius of it.
  • Doughnut: Think of a pie chart that is presented in a doughnut shape. The inner circle or hole in the middle is customizable.

The base of everything is the Chart object, which contains methods for creating and manipulating the chart types. Using the Chart object is a simple process. The following steps provide the basic approach to creating charts using the library.

  1. Include the Chart.js library in the web page.
  2. Create a Canvas element within the web page.
  3. In script, obtain the context of the Canvas element.
  4. Assemble data to be used to fill the Chart.
  5. Create the chart via script — pass context element to Chart and individual methods to create chart type (data and options passed via method).

 

The features and advantages chartjs.

  1. 100% responsive, so we do not have to worry and think about the look of our apps on all devices.
  2. 6 Chart type. We do not have to worry about running out of stock chart type, and our application will be perfect
  3. The size is only 110KB and free library dependencies with other libraries
  4. Fully tooltip, so that we can display a short information.
  5. Etc.

SETTING UP

The first thing we need to do is download ChartJs.  Then create a new html page and import the script:

DRAWING A BAR CHART

The first thing we need to do is create a canvas element in our HTML in which Chart.js can draw our chart. So add this to the body of our HTML page.

I’ll be using the CDN to include the library – using this script tag

 https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js 

Need to add Canvas in our page.

<div>
<canvas id="chartcanvas"></canvas></div>

 

11

Similarly we can create different types of charts

LINE CHART

 var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'line', data: { labels: ['M', 'T', 'W', 'T', 'F', 'S', 'S'], datasets: [{ label: 'hours slept', data: [6.5, 5, 7, 7.5, 9, 10, 6], backgroundColor: "rgba(153,255,51,0.4)", }] } }); 

LineChart.png

PIE CHART

 var ctx = document.getElementById('myChart').getContext('2d'); var myChart = new Chart(ctx, { type: 'pie', data: { labels: ['Chrome', 'Safari', 'IE', 'Firefox', 'Other'], datasets: [{ backgroundColor: [ "#2ecc71", "#3498db", "#95a5a6", "#9b59b6", "#f1c40f" ], data: [40.7, 23.9, 15.3, 11, 9.1], }] } }); 

 

PieChart

LEARN MORE……..

There is so much more to learn about Chart.js.You can also check out the Chart.js homepage for more information about what it is and what you can do.

THANK YOU!!!!!!!!!

 

Working with JsRender

JsRender is simple, lightweight but powerful templating engine. It is used for data-driven rendering of templates to strings, ready for insertion in the DOM. In the following example i am going to describe how JsRender  can be used with jQuery. When jQuery is present, JsRender loads as a jQuery plugin adds $.views, $.templates, $.render to the jQuery namespace object.

Loading JsRender with jQuery

This sample shows how the template renders against the data.

<div class="form-group">
<label for="selectState">State</label>
<select class="form-control" id="selectState">
</select>
</div>

 

In the html you see that we put our markup in a script block with type="text/x-jsrender"


<script id="StateOptionTemplate" type="text/x-jsrender">

<option value="{{:id}}">{{:value}}</option>
</script>

I am using typescript for writing the jQuery. So in my typescript file i have created a method for loading the states from the database. In the code we call the $.templates() method with a jQuery selector for that script block, to get the compiled template.


var myTemplate =$.templates("#StateOptionTemplate")

After that we run the code we have already seen to render the template against our data, and get the HTML output as a string.


var html = myTemplate.render(states);

Finally we simply insert that output into Html DOM using the jQuery html() method.


$("#" + selectState).html(html);

 

Happy coding 🙂 🙂 🙂

Dependency Injection using StructureMap in ASP.NET MVC 5

What is Dependency Injection?

Dependency Injection is nothing more than pushing dependencies of an object into constructor functions or setter properties instead of that object doing everything for itself. Main benefits are

  • Reduced Dependencies
  • More Reusable code
  • More Testable code
  • More Readable code

Di1

StructureMap is a Dependency Injection / Inversion Control tools for .NET that can be used to improve the architectural qualities of an object oriented system by reducing the mechanical cost of good design technique.

Create a project using StructureMap

Assuming you are starting with a new Asp.net MVC 5 application

Step1:  Create a new MVC project

di2

Step2: Install  the StructureMap packages

Install StructureMap,StructureMap.web, StructureMap.MVC5 packages from Nuget package manager.

DI3

once StructureMap is installed, you will notice several additions to your web project.

DI4

Step 3: Registration

The important file which is needed is the DefaultRegistry.cs.

DefaultRegistry.cs

DefaultRegistry.cs

In Default Registry class, we are going configure StructureMap container. In fact, we have two way to configure our container – by using explicit registrations or conventional auto registration.

As you can see, in this example we are composing our application object by connecting abstraction (in this case ITestInterface) to concrete type (represented by TestInterface). To do that, we are using the fluent Api For<ITestInterface>().Use<TestInterface>() which registers a default instance for a given type.

StructureMap provides auto registration and conversion mechanism which is able to register types automatically. This means, the scanner will register the default instance. Whenever you add an additional interface such IEmployeeRepository and a class EmployeeRepository, it’s automatically picked up by the scanner scan.WithDefaultConventions();

Custom Registration Conventions

It’s just not possible for StructureMap to include every possible type of auto registration convention users might want, but that’s okay because StructureMap allows you to create and use your own conventions through the IRegistrationConvention interface:

IRegistrationConvention

ControllerConvention.cs

ControllerConventions

ControllerConvention class derived from interface IRegistrationConvention. It implement the method ScanTypes.

Step 4: Create the interface ‘ITestInterface’ and the concrete implementations

To verify that things work, the simplest approach is to create an interface and an implementation of that interface, and wire them up in a controller.

ITestInterface.cs

Di6

TestInterface.cs

TestInterface

Step 5: Create a Controller

Now, we are going to create a controller. Right click on the controllers folder > Add > Controller> selecting MVC5 Controller – Empty > click Add.

HomeController

As you can see, I am creating Index() action that returns product list from GetProducts() method.

Step 6: Adding a view

It’s easy to do. Just right click on Index() action, select Add View and dialog will pop up; write a name for your View and finally, click Add.

View

Output

Now, you can run your application. Let’s see the output.

output