MVC class Besant (Practices)

https://www.c-sharpcorner.com/UploadFile/0c1bb2/contracts-in-wcf-service/

https://www.c-sharpcorner.com/UploadFile/d13d20/creating-aspnet-mvc-app-with-wcf-service-docx/

https://www.c-sharpcorner.com/UploadFile/788083/how-to-implement-message-contract-in-wcf/


https://sandippatilprogrammer.wordpress.com/2014/04/19/return-view-vs-return-redirecttoaction-vs-return-redirect-vs-return-redirecttoroute-in-mvc5/

https://www.c-sharpcorner.com/article/httpstatuscoderesult-in-asp-net-mvc/

https://www.youtube.com/watch?v=7PAIK0gPGXI

FB - C:\Users\vasan\source\repos\FBTest 

Chat - C:\Users\vasan\OneDrive\Desktop\Online Class\Projects\Live chat\chat 2\MvcDemo\MvcDemo

Advanced .Net Course Syllabus 

MVC 

Overview of the ASP.NET MVC 

https://www.tutorialsteacher.com/mvc/mvc-architecture

https://www.tutorialsteacher.com/mvc/mvc-folder-structure

Introduction of ASP.NET MVC 

Role of Model, View, and Controller 

How ASP.NET MVC Works 

Benefits of using ASP.NET MVC 

Comparison of ASP.NET VS ASP.NET MVC 

Summary 

Getting Started with MVC and its Action Result type

Action Result - > https://dotnettutorials.net/lesson/view-result-and-partial-view-result-mvc/

https://www.tutorialsteacher.com/mvc/action-method-in-mvc

https://www.tutorialsteacher.com/mvc/action-selectores-in-mvc 

Authentication

https://www.c-sharpcorner.com/article/forms-authentication-in-mvc/

Understanding the structure of an ASP.NET MVC project 

Creating views 

Defining controllers 

Defining a data model 

Overview of coding standards follows during programming 

Types of Action Result in MVC 

Summary 

Creating an application in MVC using Razor View Engine 

Create New Project

https://dotnettutorials.net/lesson/asp-dot-net-mvc-models/

viewdata

https://dotnettutorials.net/lesson/asp-dot-net-mvc-viewdata/

The ViewData in ASP.NET MVC is a mechanism to pass the data from a controller action method to a view. Let’s have a look at the signature of the ViewData.


 
ViewBag in ASP.NET MVC

understand how to use the new dynamic type ViewBag in ASP.NET MVC to pass data from a controller action method to a view.


Difference and Similarities between ViewData and ViewBag in MVC
  1. In ASP.NET MVC, we can use both ViewData and ViewBag to pass the data from a Controller to a View.

  2. The ViewData is a dictionary object whereas the ViewBag is a dynamic property. Both ViewData and ViewBag are used to create loosely typed views in MVC.

  3. In ViewData, we use the string as the key to store and retrieve the data whereas in ViewBag we use the dynamic properties to store and retrieve data.

  4. The ViewData requires typecasting for complex data type and also checks for null values to avoid any exception whereas ViewBag doesn’t require any typecasting for the complex data type.

  5. Both the ViewData keys and ViewBag dynamic properties are resolved only at runtime. As a result, both do not provide compile-time error checking and because of this, we will not get any intelligence support.

  6. So if we misspell the key names or dynamic property names then we will not get any compile-time error rather we came to know about the error only at run time. This is the reason why we rarely used ViewBag and ViewData in our application.

 



Creating strongly-typed views 

Strongly typed views are used for rendering specific types of model objects, instead of using the general ViewData structure. By specifying the type of data, you get access to IntelliSense for the model class


In order to create a strongly typed view in ASP.NET MVC, we need to specify the model type within the view by using the @model directive. As here, the Employee class is going to be the model so we need to specify the model directive as shown below.

@model FirstMVCDemo.Models.Employee

The above statement will tell that we are going to use FirstMVCDemo.Models.Employee as the model for this view. Here in the directive (@model), the letter m is in lowercase and the statement should not be terminated with the semicolon.

Then we can access the model properties simply by using @Model, here the letter M is in uppercase. So, in our example, we can access the Employee object properties such as Name, Gender, City, Salary, etc. by using @Model.Name, @Model.Gender, @Model.City, and @Model.Salary respectively.

 

Advantages of using Strongly Typed View in ASP.NET MVC Application: 

We will get the following advantages when we use strongly typed view in ASP.NET MVC application.

  1. Strongly Typed View in ASP.NET MVC provides compile-time error checking as well as intelligence support.

  2. If we misspell the property name, then it comes to know at compile time rather than at runtime.

In our example, we are still using ViewBag to pass the Header from Controller to the View. Then the question that comes to your mind is how we will pass the Header to a strongly typed view without using ViewBag. Well, we can do this by using the View Model in ASP.NET MVC application.

View Model

https://dotnettutorials.net/lesson/view-model-asp-net-mvc/

TempData 

https://dotnettutorials.net/lesson/asp-dot-net-mvc-tempdata/

The limitation of both ViewData and ViewBag is they are limited to one HTTP request only. So, if redirection occurs then their values become null means they will lose the data they hold. In many real-time scenarios, we may need to pass the data from one HTTP Request to the next subsequent HTTP Request. For example, we may need to pass the data from one controller to another controller or one action method to another action method within the same controller. Then in such situations like this, we need to use TempData.

How to Pass and Retrieve data From TempData in ASP.NET MVC:

The most important point that you need to remember is, as it stores the data in the form of an object so while retrieving the data from TempData type casting is required.

If you are accessing string value from the TempData, then it is not required to typecast

But it is mandatory to typecast explicitly to the actual type if you are accessing data other than the string type from the TempData.

 

 
How to retain TempData values in the consecutive request?

As you can see in the above example, we add Name and Age in TempData in the first request and in the second subsequent request we access the data from the TempData which we stored in the first request. However, we can’t get the same data in the third request because TempData will be cleared out after the second request


In order to retain the TempData value in the third consecutive request, we need to call TempData.Keep() method. Let’s see the use of TempData.Keep() method  with an example

 

 

Understanding URLs and action methods 

What are the different types of Routing supported by ASP.NET MVC?

In ASP.NET MVC application, we can define routes in two ways. They are as follows:

  1. Convention Based Routing

  2. Attribute-Based Routing.

  3.  


In simple word, we can say that ASP.NET MVC Routing is a pattern matching mechanism that handles the incoming request (i.e. incoming URL) and figures out what to do with that incoming request (i.e. incoming URL).

At runtime, Routing engine uses the Route table for matching the incoming request’s URL pattern against the URL patterns defined in the Route table. We can register one or more URL patterns to the Route table at Application_Start event.

When the routing engine finds a match in the routing table for the incoming request, it forwards the request to the appropriate controller and action. If there is no match found in the routing table for the incoming request, then it simply returns a 404 HTTP status code.


The routing functionality is implemented in the System.Web.Routing.


How to Configure a Route in ASP.NET MVC?

Every MVC application must configure (register) at least one route in the RouteConfig class and by default MVC Framework provide one default route. But you can configure as many as routes you want. You can register a route in the RouteConfig class, which is in RouteConfig.cs file under the App_Start folder as shown below.


The following code illustrates how to configure a Route in the RouteConfig class.


namespace FirstMVCDemo

{

    public class RouteConfig

    {

        public static void RegisterRoutes(RouteCollection routes)

        {

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            routes.MapRoute(

                name: "Default", //Route Name

                url: "{controller}/{action}/{id}", //Route Pattern

                defaults: new

                {

                    controller = "Home", //Controller Name

                    action = "Index", //Action method Name

                    id = UrlParameter.Optional //Defaut value for above defined parameter

                }

            );

        }

    }

}

Let’s Understand the above Code:

As you can see in the above code, the Routing is configured using the MapRoute() extension method of RouteCollection class, where the Route name is “Default” and the URL pattern is “{controller}/{action}/{id}“. The Defaults value for the controller is Home, and the default action method is Index and the id parameter is optional.


Custom Routing


As we already discussed the Routing is a pattern matching mechanism that handles the incoming request (i.e. incoming URL) and figures out what to do with that incoming request (i.e. incoming URL). The following diagram shows the routing process work in ASP.NET MVC Application.

Custom Routing in ASP.NET MVC Application


In our previous article, we discussed the default route that is created by MVC Framework and how it handles the incoming request. But if you want to follow your own convention then you would need to modify the default route or you need to create your own route. Let’s discuss how to create your own route in ASP.NET MVC application.



All Routing Concepts in 

https://dotnettutorials.net/lesson/asp-dot-net-mvc-routing/

 
How is the routing table created in ASP.NET MVC?

When an MVC application first starts, the Application_Start() method in global.asax is called. This method calls the RegisterRoutes() method. The RegisterRoutes() method creates the routing table for the MVC application.





TempData, view Bag and View  Data with example 

---------start

Data Annotations 


In ASP.NET MVC web applications, we can do the following three types of validations:
  1. HTML validation / JavaScript validation (i.e. Client-Side Validation)

  2. ASP.NET MVC Model validation (i.e. Server-side Validation)

  3. Database validation (i.e. Server-side Validation)

Among the above three, the most secure validation is the ASP.NET MVC model validation. In HTML/JavaScript validation, the validation can break easily by disabling the javascript in the client machine, but the model validation can’t break.


The System.ComponentModel.DataAnnotations assembly has many built-in validation attributes, for example:
  1. Required

  2. Range

  3. RegularExpression,

  4. Compare

  5. StringLength

  6. Data type

Along with the above build-in validation attributes, there are also many data types the user can select to validate the input. Using this data type attribute, the user can validate for the exact data type as in the following:

  1. Credit Card number

  2. Currency

  3. Custom

  4. Date

  5. DateTime

  6. Duration

  7. Email Address

  8. HTML

  9. Image URL

  10. Multiline text

  11. Password

  12. Phone number

  13. Postal Code

  14. Upload


(Valid indicates if it was possible to bind the incoming values from the request to the model correctly and whether any explicitly specified validation rules were broken during the model binding process. In your example, the model that is being bound is of class type Encaissement)

https://dotnettutorials.net/lesson/data-annotation-attributes-mvc/

Validation in MVC 

Razor Basics and Implementation of Razor view 

Accessing Model Data in Razor views 

Defining and using HTML Helpers 

Defining and Designing a layout Page 

Defining and using partial views 

https://www.tutorialsteacher.com/mvc/partial-view-in-asp.net-mvc

Using AJAX and jQuery with ASP.NET MVC 

DB First CURD With Bootstrap & notify Alert

C:\Users\vasan\OneDrive\Desktop\Online Class\Projects\@MVC\CRUDAjax

https://www.c-sharpcorner.com/article/crud-operation-in-asp-net-mvc-using-ajax-and-bootstrap/

Overview of AJAX 

Using AJAX Action Links 

Overview of jQuery 

jQuery Techniques 

Using post and get methods in jquery 

Using AJAX and Jquery in MVC with Example 

Overview of Entity Framework and its approaches 

OverView of Entity Framework 

Code First Approach with example  

C:\Users\vasan\source\repos\Repository_MVC

https://www.dotnetcurry.com/aspnet-mvc/889/entity-framework-code-migration-aspnet-mvc

Model First Approach with example 

Database First Approach with example 

Working with ASP.NET MVC Applications using EF Approaches Code First, Model First, Database first 

ASP.NET application architecture best practices 

Implementing a Repository and Entity Framework Data Model 

Overview of Repository Pattern

The repository pattern is intended to create an abstraction layer between the data access layer and the business logic layer of an application. It is a data access pattern that prompts a more loosely coupled approach to data access. We create the data access logic in a separate class, or set of classes, called a repository with the responsibility of persisting the application's business model.

MVC controllers interact with repositories to load and persist an application business model. By taking advantage of dependency injection (DI), repositories can be injected into a controller's constructor.

Repository Pattern in MVC

Why Repository Pattern C# ?

The advantage of doing so is that, if you need to do any change then you need to do in one place

 Another benefit is that testing your controllers becomes easy because the testing framework need not run against the actual database access code

Centralized View For DB Access Methods

  • Increase testability: Repository systems are good for testing. One reason being that you can use Dependency Injection. Basically, you create an interface for your repository, and you reference the interface for it when you are making the object. Then you can later make a fake object (using moq for instance) which implements that interface. Using something like StructureMap you can then bind the proper type to that interface. Boom you’ve just taken a dependence out of the equation and replaced it with something testable.

  • Easily swapped out with various data stores without changing the API: For example, in one instance, you may need to retrieve data from the database, in other cases you may need to retrieve something from a third-party API, or perhaps there’s some other place from which you need to retrieve data. Regardless, the idea behind the repository pattern is that whatever sits behind it doesn’t matter so long as the API it provides works for the layer of the application calling into it.

Why we need the Repository Pattern in C#?

As we already discussed, nowadays, most of the data-driven applications need to access the data residing in one or more other data sources. Most of the time data sources will be a database. Again, these data-driven applications need to have a good and secure strategy for data access to perform the CRUD operations against the underlying database. One of the most important aspects of this strategy is the separation between the actual database, queries and other data access logic from the rest of the application. In our example, we need to separate the data access logic from the Employee Controller. The Repository Design Pattern is one of the most popular design patterns to achieve such separation between the actual database, queries and other data access logic from the rest of the application.

https://www.c-sharpcorner.com/UploadFile/3d39b4/crud-using-the-repository-pattern-in-mvc/


https://www.c-sharpcorner.com/UploadFile/8a67c0/repository-pattern-with-Asp-Net-mvc-with-entity-framework/

Enable-Migrations -ContextTypeName Repository_MVC.DAL.BookContext

add-migration Initial

update-database


Define Dependency Injection 

Dependency Injection (DI) is a design pattern used to implement IoC. It allows the creation of dependent objects outside of a class and provides those objects to a class through different ways. Using DI, we move the creation and binding of the dependent objects outside of the class that depends on them

Using Dependency Injection 

Accessing a Repository in controller 

Import and Export Excel file in MVC 

C:\Users\vasan\source\repos\ExcelExport

For Import

Import BY DB            (issue)

Install Link

Issue - https://stackoverflow.com/a/18019651

Basics of I/O classes in MVC 

Basics of input and output streams. 

Create the excel document with records and create the view to upload/import the excel 

How to import an excel from view to the database 

Export the Data from Database to excel 

Summary 


Convert web grid into PDF file in MVC 

 WebGrid component into an ASP.NET MVC environment to enable you to be productive when rendering tabular data. I’ll be focusing on WebGrid from an ASP.NET MVC aspect: creating a strongly typed version of WebGrid with full IntelliSense, hooking into the WebGrid support for server-side paging and adding AJAX functionality that degrades gracefully when scripting is disabled. The working samples build on top of a service that provides access to the AdventureWorksLT database via the Entity Framework.

https://www.aspsnippets.com/Articles/Export-WebGrid-with-Formatting-to-PDF-file-in-ASPNet-MVC.aspx

Create the view using web grid 

How to convert the webgrid into pdf 

Summary 

Sending Emails 

C:\Users\vasan\OneDrive\Desktop\Online Class\WCT_and_email_mvc\Send_Email_Attachment_MVC

Designing email panel 

Local - Send_Email_Attachment_MVC

https://myaccount.google.com/security

How to send an email to various users 

Sending auto emails 


Summary 


Integration of WCF service with MVC 

Basics of WCF service creation 

What is WCF?

How to install ( Windows communication Foundation )

WCF stands for Windows Communication Foundation and is part of .NET 3.0. WCF is Microsoft platform for building distributed and interoperable applications.




What is a distributed application?

In simple terms a distributed application, is an application where parts of it run on 2 or more computers. Distributed applications are also called as connected systems.


Examples:

A web application running on one machine and a web service that this application is consuming is running on another machine.

Distributed System


An enterprise web application may have the following tiers, and each tier may be running on a different machine

1. Presentation tier

2. Business tier

3. Data Access tier

Connected System


Why build distributed applications?

There are several reasons for this

1. An enterprise application may need to use the services provided by other enterprises. For example an ecommerce application may be using Paypal service for payments.

2. For better scalability. An enterprise web application may have Presentation tier, Business tier, and Data Access tier, and each tier may be running on a different machine.


What is an interoperable application?

An application that can communicate with any other application that is built on any platform and using any programming language is called as an interoperable application. Web services are interoperable, where as .NET remoting services are not.


Web services can communicate with any application built on any platform, where as a .NET remoting service can be consumed only by a .net application.


What technology choices did we have before WCF to build distributed applications?

Enterprise Services

Dot Net Remoting

Web Services


Why should we use WCF?

Let's take this scenario

We have 2 clients and we need to implement a service a for them. 

1. The first client is using a Java application to interact with our service, so for interoperability this client wants messages to be in XML format and the protocol to be HTTP.

2. The second client uses .NET, so for better performance this client wants messages formatted in binary over TCP protocol.


Without WCF

1. To satisfy the first client requirement we end up implementing an ASMX web service, and

asp.net web service example


2. To satisfy the second client requirement we end up implementing a remoting service

Dot Net Remoting Example


These are 2 different technologies, and have complete different programming models. So the developers have to learn different technologies. 


So to unify and bring all these technologies under one roof Microsoft has come up with a single programming model that is called as WCF - Windows Communication Foundation.


With WCF,

You implement one service and we can configure as many end points as want to support all the client needs. To support the above 2 client requirements, we would configure 2 end points. In the endpoint configuration we can specify the protocols and message formats that we want to use.

WCF Example


In Part 2, we will discuss implementing 

1. A web service to exchange messages in XML format using HTTP protocol for interoperability.

2. A remoting service to exchange messages in binary format using TCP protocol for performance.

Along the way, we will get a feel of how different these technologies are.


In Part 3, we will discuss implementing a single WCF Service and configuring different end points to support different transport protocols and message formats.


https://www.c-sharpcorner.com/UploadFile/d13d20/creating-aspnet-mvc-app-with-wcf-service-docx/

ServiceContract 

The ServiceContract attribute marks a type as a Service Contract that contains operations. OperationContract attribute marks the operations that will be exposed. FaultContract defines what errors are raised by the service being exposed

OperationContract 

[OperationContract] attribute is used to define the methods of service contract. This attribute is placed on methods that you want to include as a part of service contract. Only those methods that are marked with OperationContract attribute are exposed to client.Apr 24, 2017

Difference Between WCF and Web Service

WCF and its types of contracts 

How to consume the WCF service with MVC 

Summary 

Creating a sample MVC Application using AJAX and JQUERY, WCF service and Repository in MVC 

Design, Develop and Build the MVC Application using all the functionalities (Jquery, wcf, repository, ajaxcalls etc.,) 

WCF Training Course Syllabus WPF Training Course Syllabus 

Not IN SYllabus

Worked

https://www.c-sharpcorner.com/article/role-based-authentication-in-asp-net-mvc/

C:\Users\vasan\OneDrive\Desktop\Online Class\Projects\RoleAuth2

The basic purpose of ValidateAntiForgeryToken attribute is to prevent cross-site request forgery attacks. A cross-site request forgery is an attack in which a harmful script element, malicious command, or code is sent from the browser of a trusted user

Theory

[AllowAnonymous]

RoleBased

if you Authorize a role to access a controller ( at class level ) or a action ( function level ) they roles will have access. otherwise the access is denied.

if you use just the Authorize keyword without specifying the roles or users, all authenticated users will have access.

hope fully i am making it clear ?



C:\Users\vasan\OneDrive\Desktop\Online Class\RoleBasedAuth

https://www.c-sharpcorner.com/article/role-based-menus-in-asp-net-mvc/

-----------

https://www.c-sharpcorner.com/article/authentication-and-authorization-in-mvc/

https://www.c-sharpcorner.com/article/authorization-filter-in-asp-net-mvc/


Work on custom role based authentication

(Code First)

https://www.dotnettricks.com/learn/mvc/custom-authentication-and-authorization-in-aspnet-mvc

(DB First)

https://www.c-sharpcorner.com/article/custom-authentication-with-asp-net-mvc/


HttpContext

A HttpContext object holds information about the current HTTP request. ... As the request is created in each HTTP request, it ends too after the finish of each HTTP request or response.

DB First CURD With Bootstrap & notify Alert

https://www.c-sharpcorner.com/article/create-asp-net-mvc-crud-application-with-entity-framework-using-ajax-request-and2/

C:\Users\vasan\OneDrive\Desktop\Practice Projects\CURD_MVC_DB_First

Error Handle with err code

Code Description Notes

400 Bad Request This is the generic error that tells us someone created a bad request. Perhaps required fields are missing or header values are not filled in.

401 Unauthorized Indicates that authentication has failed. This could be because of an expired, missing, or invalid token.

403 Forbidden Indicates that authorization failed. Alternatively, you can also use 404 so that the consumer doesn’t know that the resource even exists.

404 Not Found The requested resource is not found. Companies like GitHub also use 404 if you try to access a resource that you do not have the authorization to access.

500 Internal Server Error When something goes wrong on the server, the consumer can’t do anything about it. Just let them know there’s a problem and that they should try again later or contact support.

<system.web>

    <customErrors mode="On" defaultRedirect="~/ErrorHandler/Index">

        <error statusCode="404" redirect="~/ErrorHandler/NotFound"/>

    </customErrors>

<system.web/>



https://stackify.com/aspnet-mvc-error-handling/

Online Shopping 

http://www.webdevelopmenthelp.net/2016/10/asp-net-mvc-shopping-cart-part1.html

 Online Shopping Store Features List


Features covered in ASP.NET MVC Online Shopping Sto e – Part 1

Overall ASP.NET MVC Project Setup

Online Shopping Store Database Setup

Administration – All CRUD Operations for Categories

Administration – All CRUD Operations for Products

Administration – Mark a Product as Featured Product

Features covered in ASP.NET MVC Online Shopping Store – Part 2

User Registration & Authentication

Product Display Center

Search Products

Display Products by Category e.g Mobiles/Tables | Home Appliances | Other Electronics etc.

Products List View

Single Product Detailed View

Shopping Cart – Add Products to Cart

Cart View – List of Products added to Shopping Cart

Remove Products from Shopping Cart

Features covered in ASP.NET MVC Online Shopping Store – Part 3

Checkout Option

Shipping Details

Payment Options Dummy Page

Place Order

Order Summary Page on successful payment

Administration – View/List Orders

Administration – Single Order Detailed View


Additional

  • Live Chat Option with Customer Care 

  • Live Notification From FireBase

    • Integrate FB with MVC Project

    • Configure Token Setup

    • Send daily notification

    • Send Scheduled Notification

  • Generating Auto Receipt Email For Orders , And Cancellation

  • Sending Live Sms For Order Update

  • Google Map Location Preview with Marker

https://www.tooplate.com/free-templates

https://themewagon.com/free-html-ecommerce-templates-html5-bootstrap/




Comments

Popular Posts