Showing posts with label ASP.NET MVC. Show all posts
Showing posts with label ASP.NET MVC. Show all posts

Thursday, August 6, 2020

What is ASP.NET MVC 4 Dependency Injection please explain step by step

In Object-Oriented Programming paradigm, objects work together in a collaboration model where there are contributors and consumers. Naturally, this communication model generates dependencies between objects and components, becoming difficult to manage when complexity increases.

Wednesday, August 5, 2020

What is Difference Between Each Version Of MVC 2, 3 , 4, 5 And 6

Difference between each version of 
MVC 2.0, 
MVC 3.0, 
MVC 4.0, 
MVC 5.0, 
and MVC 6.0 

MVC 6

ASP.NET MVC and Web API have been converted into one.
Reliance infusion is inbuilt and part of MVC.
Next to each other - convey the runtime and structure with your application
Everything is bundled with NuGet, Including the .NET runtime itself.
New JSON based venture structure.
No compelling reason to recompile for each change. Simply hit space and revive the program.
Accumulation finished with the new Roslyn ongoing compiler.
vNext is Open Source by means of the .NET Foundation and is taking open commitments.
vNext (and Rosyln) additionally keeps running on Mono, on both Mac and Linux today.

MVC 5

One ASP.NET
Trait based directing
Asp.Net Identity
Bootstrap in the MVC layout
Confirmation Filters
Channel supersedes

MVC 4


ASP.NET Web API
Revived and modernized default venture formats
New versatile venture format
Numerous new highlights to help portable applications
Upgraded bolster for nonconcurrent techniques

MVC 3

Razor
Readymade venture formats
HTML 5 empowered formats
Support for Multiple View Engines
JavaScript and Ajax
Demonstrate Validation Improvements

MVC 2


Customer Side Validation
Templated Helpers
Regions
Nonconcurrent Controllers
Html.ValidationSummary Helper Method
DefaultValueAttribute in real-life Method Parameters
Restricting Binary Data with Model Binders
DataAnnotations Attributes
Demonstrate Validator Providers
New RequireHttpsAttribute Action Filter
Templated Helpers
Show Model-Level Errors

WEB API - Interview Questions and Answers . ?

How do I use exception filter in WEB API.?
How can you handle errors in WEB API.?
What are API errors?
How do I debug WebAPI.?
What is APU server error.?
How do I get a 500 error page.?
What is a 500 response code.?
What does error code 401 mean.?
How do you fix a 401 error.?
How do I get a 401 error.?
How do I create a 401 error.?
How do you fix 401 unauthorized error in Postman.?
What is 401 Authorisation required.?
What is 404 HTML.?
Why is 404 the error code.?
How do I get a 404 erro page.?
How do I fix Error 404.?
What is a 504 error.?
What does 403 Forbidden mean.?

MVC - Interview Questions and Answers ASP.NET MVC.?

Filters in mvc
Globle exception filter in mvc
exception filter vs try catch in mvc
authorization filter in mvc
exception handling in mvc
authentication filter in mvc exception filter in web api
What is filter MVC. ?
How can use exception filters in MVC with example?
How can use expception handling in MVC?
What is exception handling in MVC.?
What are the types of filters in MVC.?
What is MVC life Cycle.?
Can we use view state in MVC
What is ViewStart MVC.?
What is --- viewstate.?
What is session in MVC C#.?
Is it good to use session in MVC?
What is Session C#.?
What is difference between keep and peek in MVC.?
Why ViewData is faster than ViewBag.?
What is HTML helpers in MVC.?
What is the difference between session and TemData in MVC.?
What are the 3 types of sessions?
Does TempData use session.?
Is TempData secure.?
Where is TempData stored.?
How do I use TempData.?
Is ViewBag secure.?
Why ViewBag is used in MVC.?
How check ViewBag is null in MVC.?
What is strongly typed view in MVC.?
What is MVC scaffolding.?
What is difference between model and ViewModel in MVC.?
What is difference between TextBox and TextBoxFor in MVC.?
How disable HTML TextBoxFor in MVC.?
What is the razor in MVC.?
What is HTML attribute MVC.?
What is difference between EditorFor and TextBoxFor in MVC.?
What is HTML HiddenFor.?
What is model biding in MVC.?
What is model in MVC C#.?
What is the use of ViewModel in MVC.?
What is action result MVC.?
Can we overload MVC action methods.?
What are the types of action results in MVC?
What are the action filters in MVC.?
What are the return Types in MVC.?
Various Return Types From MVC Controller
System.Web.Mvc.ContentResult.
System.Web.Mvc.EmptyResult.
System.Web.Mvc.FileResult.
System.Web.Mvc.HttpStatusCodeResult.
System.Web.Mvc.JavaScriptResult.
System.Web.Mvc.JsonResult.
System.Web.Mvc.RedirectResult.
System.Web.Mvc.RedirectToRouteResult.
What is REdirectToAction MVC.?
Can ActionResult return JSON.?
How do we maintain session in MVC.?
Which is the best approach to assign a session in MVC.?
What is return view in MVC.?
How do I pass model in RedirectToAction.?
How to pass data from one view to another in MVC.?
How pass data from one action method to another action method in MVC.?
How to pass data from view to view in MVC.?
Can we pass data from controller to view using TempData.?
What is difference between ViewBag and ViewData in MVC.?
Can you explain RenderBody and REnderPage in MVC.?
Should I use ViewBag or ViewData.?
Does ViewBag use session.?
What is the difference between ViewBag , ViewData and TempData.?
Where is ViewBag stored.?
What is the use of TempData in MVC.?
What is data annotation in MVC.?
----------------------------------------
How do I use exception filter in WEB API.?
How can you handle errors in WEB API.?
What are API errors?
How do I debug WebAPI.?
What is APU server error.?
How do I get a 500 error page.?
What is a 500 response code.?
What does error code 401 mean.?
How do you fix a 401 error.?
How do I get a 401 error.?
How do I create a 401 error.?
How do you fix 401 unauthorized error in Postman.?
What is 401 Authorisation required.?
What is 404 HTML.?
Why is 404 the error code.?
How do I get a 404 erro page.?
How do I fix Error 404.?
What is a 504 error.?
What does 403 Forbidden mean.?

Sunday, August 2, 2020

Recent questions asking in interview - C# , asp.net , asp.net mvc , asp.net core , sql , entity framework

 Q. Sql Injection 
 Q. Sql cache 
 Q. Exception Filter purpose
Q. MVC Validations - Jquery ka use yaha par 
Q. Await Async




1. What is the difference between SingleOrDefault and FirstOrDefault?

LINQ provides element operators that return a single element or a specific element from a collection. The elements operators are Single, SingleOrDefault, First, FirstOrDefault, Last, LastOrDefault.

Single

It returns a single specific element from a collection of elements if element match found. An exception is thrown, if none or more than one match found for that element in the collection.
SingleOrDefault

It returns a single specific element from a collection of elements if element match found. An exception is thrown, if more than one match found for that element in the collection. A default value is returned, if no match is found for that element in the collection.

First

It returns first specific element from a collection of elements if one or more than one match found for that element. An exception is thrown, if no match is found for that element in the collection.

FirstOrDefault

It returns first specific element from a collection of elements if one or more than one match found for that element. A default value is returned, if no match is found for that element in the collection.

When to use Single, SingleOrDefault, First and FirstOrDefault

You should take care of following points while choosing Single, SingleOrDefault, First and 
FirstOrDefault:
When you want an exception to be thrown if the result set contains many records, use Single or SingleOrDefault.
When you want a default value is returned if the result set contains no record, use SingleOrDefault.
When you always want one record no matter what the result set contains, use First or FirstOrDefault.
When you want a default value if the result set contains no record, use FirstOrDefault.

Perfomance of SingleOrDefault and FirstOrDefault

FirstOrDefault usually performs faster as compared to SingleOrDefault, since these iterate the collection until they find the first match. While SingleOrDefault iterates the whole collection to find one single match.

Q.2 AllowAnonymous Attribut and Authorize Attribute.?

One of the new features in ASP.NET MVC 4 is the AllowAnonymous Attribute that helps you secure an entire ASP.NET MVC 4 Website or Controller while providing a convenient means of allowing anonymous users access to certain controller actions, like the login and register Actions.


AllowAnonymous Attribute in ASP.NET MVC 4

As mentioned, if you create a new ASP.NET MVC 4 Internet Project in Visual Studio 2010 or Visual Studio 11 and view the AccountController you will notice the generous use of the AllowAnonymous Attribute on various login and register controller actions. Here are a few of those controller actions.

[Authorize] 
public class AccountController : Controller 
 [AllowAnonymous] 
 public ActionResult Login() 
 // ... 
 } 
 [AllowAnonymous]
 [HttpPost] 
 public JsonResult JsonLogin(LoginModel model, string returnUrl) 
 // ...
 }
 [AllowAnonymous]
 [HttpPost] 
 public ActionResult Login(LoginModel model, string returnUrl) 
 // ... 
 }
 [AllowAnonymous] public ActionResult Register() 
 // ... 
 } 
 [AllowAnonymous] 
 [HttpPost] 
 public ActionResult JsonRegister(RegisterModel model)
 {
 // ... 
 }
 [AllowAnonymous]
 [HttpPost] 
 public ActionResult Register(RegisterModel model) 
 // ... 
 } 
}

The idea is pretty simple. The Authorize Attribute on the AccountController in this ASP.NET MVC 4 Application denies anonymous access to every controller action. However, we need to allow anonymous access to the login and register controller actions so we decorate them with the AllowAnonymous Attribute which negates the Authorize Attribute and allows anonymous access.

Q.3 What is mvc Filters and custom filters . ?


ASP.NET MVC provides Action Filters for executing filtering logic either before or after an action method is called. Action Filters are custom attributes that provide declarative means to add pre-action and post-action behavior to the controller's action methods.

Q.4 What is Dependency injection with examples . ?

In software engineering, dependency injection is a technique in which an object receives other objects that it depends on. These other objects are called dependencies. In the typical "using" relationship the receiving object is called a client and the passed object is called a service.


Wednesday, April 1, 2020

Top 10 ASP.NET MVC Interview Q & A

1. What is ASP.NET MVC ?

ASP.NET MVC is a web application framework. it is lightweight and highly testable framework. MVC separate application into three components- Model, View and Controller.

2. Can you explain Model, View and Controller in MVC ?

Model - its business entity and it is used to represent the application data.
Controller - request sent by the user always scatters through controller and its responsibility is to redirect to the specific view using View() method.
View- if the presentation layer of MVC.

3. Explain the new features added in version 4 of MVC( MVC4) ?

following features added newly-
Asynchronous controller task support
building the JavaScript.
segregating the config for MVC routing, Web API, Bundle etc.
mobile templates.
added ASP.NET Web API template for creating REST based services.
Bundling the JavaScript .

4. Can you explain the page life cycle of MVC ?

below are the process followed in the sequence -
App initialisation
Routing
Instantiate and execute controller
Locate and invoke controller action
Instantiate and render view 

5. what are the advantages of MVC over ASP.NET ?

Provides a clean separation of concerns among UI ( Presentation layer), model ( Transfer objects / Domain objects/ Entities) and Business logic ( Controller).
Easy to UNIT test.
improved reusability of model and views. we can have multiple views which can point to the same model and vice versa .
improved structuring of the code.

6. what is separation of concerns in ASP.NET MVC?

it's the process of breaking the program into various resident features which overlaps in functionality as little as possible. MVC pattern concerns on separating the content from presentation and data processing from content.

7. what is Razor View Engine ?

Razor is the first major update to render HTML in MVC 3. razor was designed specifically for view engine syntax. main purpose of this would be to simplify and code for girls templating for HTML generation. below is the sample of using razor:
@model MvcMusicStore.Models.Customer

@{ViewBag.Title = “Get Customers”;}

<div class=”cust”> <h3><em>@Model.CustomerName</em> </h3>

8. What is the meaning of Unobtrusive JavaScript ?

this is a General term that conveys general philosophy, similar to the term REST ( Representational State Transfer) . Unobtrusive JavaScript code in your page markup.

Example: instead of using events like onclick and onsubmit, Unobtrusive JavaScript attaches to Elements by their ID or class based on the HTML5 data attributes. in a line

9. what is the use of ViewModel in MVC ?

ViewModel is a plane class with properties, which is used to bind it too strongly typed view. ViewModel can have the validation rules defined for its properties using the data annotations.

10. what do you mean by Routing in MVC ?

routing is a pattern matching mechanism of incoming request to the URL pattern which are registered in route table. Class- “URLRoutingModule” is used for the same process.

11. What are actions in MVC ?


Actions are the methods in controller class which is responsible for returning the view or JSON data. action will mainly have return type - “ActionResult” and it will be in work from method - “InvokeAction” called by the controller.

Rewrite whole Web Site System and Sub System with data migration to new system.

Can you please share me your skype id or whats up number for better communications  my skype id is - jitendra.tech  whats up - +919617741414...