Others

Sunday, 17 June 2018

AngularJs 4 Tutorial in 4 days


Day 1

Prerequesite of angular Framework
History of angular
Angular Features
Node Configurations (Lab 1)
File Structure of Angular
First Application (Lab 2)
Create Child Component (Lab 3)
Angular Directives
Directive Code practice (Lab 3)

Prerequesite of angular Framework

HTML
CSS
NodeJs
Typescript

 History of angular

Angular 1.x
Angular 2 -- Angular
Angular 3 - routing -- 3.x
Angular 4,5,6


Angular Features


·         Transpilation :  The process of converting one version of  JS cod to other (preferrbaly lower version) Transpiler is a tool which does this. Babel is commenly used transpiling module...
React js  - JSX -- ES5
JSX - Javascript XML

Angular --- Type Script -- ES5 [ Converted using typescript compiler)

Saturday, 26 May 2018

OAuth Integration with MVC WebApi


What is OAuth

oAuth stands for Open Authorization. It helps to access the resource in secured way , when the resource owner want it to share to any third party provider.
Like you logged in to the twitter and now you want to send a friend request to all your google address book user. So you can login securely to the google and than google will authenticate and share the entire address book to twitter and that you can use to send the friend request.

How it Work


User has logged into as is user credential  into seeker Resource (SR) now he want to get the details from third party resource(RO)  where he already have account. He has to provide the credentials than third party resource owner (RO) will allocate the security token. Then Seeker Resource (SR) will send the Security token to the resource Owner(RO), and it will give the details of resource what Seeker Resource want.

Add a startup.cs class to your application


Startup page is mostly using to configuration for startup of the application when you are configuration OWIN or the OAuth authorization.

There are two what you can directly add it and  as a class file and decorate it as. OWinStartup:

  [assembly: OwinStartup(typeof(WebApiOAuth_1.App_Start.Startup))]


Or you can create startup.cs through the Visual Video by using the below process.
a.       Rt click on App_Start à Add à Class

XMLformatting in c#



Format the minify XML into readable way which help to view it properly and easy to read in C#. You can make your simple xml formatter by using the below few lines of code in C#.
static void Main(string[] args)
        {
            try
            {
                string xml = @"<?xml version='1.0' encoding='UTF - 8' ?><employees><employee><id>1</id><firstName>Leonardo</firstName>
            <lastName>DiCaprio</lastName><photo>http://1.bp.blogspot.com/-zvS_6Q1IzR8/T5l6qvnRmcI/AAAAAAAABcc/HXO7HDEJKo0/s200/Leonardo+Dicaprio7.jpg</photo>
            </employee><employee><id>2</id><firstName>Johnny</firstName><lastName>Depp</lastName>
            <photo>http://4.bp.blogspot.com/_xR71w9-qx9E/SrAz--pu0MI/AAAAAAAAC38/2ZP28rVEFKc/s200/johnny-depp-pirates.jpg</photo>
            </employee><employee><id>3</id><firstName>Hritik</firstName><lastName>Roshan</lastName><photo>http://thewallmachine.com/files/1411921557.jpg</photo>
            </employee></employees> ";

Thursday, 24 May 2018

Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'


Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 


Sunday, 20 May 2018

Binding DropDownList in MVC


In MVC we have 2 ways to bind the dropdown is strongly type and nomal way.
There are various ways that you can bind the dropdownlist in MVC.

1.       Binding Dropdownlist  using the view bag in MVC
Binding SelectedList to Dropdown

  List<SelectListItem> items = new List<SelectListItem>();
            items.Add(new SelectListItem() { Text = "Male", Value = "Male", Selected = false });
            items.Add(new SelectListItem() { Text = "Female", Value = "Female", Selected = true });

            SelectList selectList = new SelectList(items, "Value", "Text");


            ViewBag.Gender = selectList;

Binding it in HTML, like below
  @Html.DropDownList("Gender", ViewBag.Gender as SelectList)

Will get output as below.

Friday, 18 May 2018

Format date in ui-grid cellTemplate


This sample is using when you are implementing MVC with Angular 1.x and Angular Ui Grid.
Formatting of date field will be appearing like:



Sunday, 13 May 2018

Handling Exception in Global.asax in MVC



Instead of writing the try and catch throughout the application, global.asax , application_error method is the common place to handle all the error and based on the type of exception it will redirect to the page.



Tuesday, 8 May 2018

Selecting the active link in MVC



Based on selection or opening of the controller action the link will select in MVC like below.




There should you need to provide the css dynamically which is based on the action. You need to create the CSS style.
.activelink {
    color: #ffffff;
    background-color: #de0301;
    border-radius: 10px;
    margin-left: 4px;
}
If you see the below code there we are checking the (ViewContext.RouteData.Values["Controller"].ToString() == "Home"

Thursday, 19 April 2018

Provide security to Your WebApi using HttpMessageHandler


Using of HttpMessageHandler, help you to secure your WebApi action method, Even though it’s not the full proof security. But it is good to provide security based on tokens.

Step 1: Create A Web API project.
Follow below:

Step 2: Add a class file and giving the name as:

That You can give as any name