Posts

List out different return types of a controller action method?

There are total nine return types we can use to return results from controller to view.  The base type of all these result types is ActionResult. ViewResult (View) : This return type is used to return a webpage from an action method. PartialviewResult (Partialview) : This return type is used to send a part of a view which will be rendered in another view. RedirectResult (Redirect) : This return type is used to redirect to any other controller and action method depending on the URL. RedirectToRouteResult (RedirectToAction, RedirectToRoute):  This return type is used when we want to redirect to any other action method. ContentResult (Content) : This return type is used to return HTTP content type like text/plain as the result of the action. jsonResult (json):  This return type is used when we want to return a JSON message. javascriptResult (javascript):  This return type is used to return JavaScript code that will run in browser. FileResult (File): ...

Is it True that ASP.NET Web API has Replaced WCF?

It's a misconception that ASP.NET Web API has replaced WCF. It's another way of building non-SOAP based services, for example, plain XML or JSON string, etc. Yes, it has some added advantages like utilizing full features of HTTP and reaching more clients such as mobile devices, etc. But WCF is still a good choice for following scenarios: If we intended to use transport other than HTTP, e.g. TCP, UDP or Named Pipes Message Queuing scenario using MSMQ One-way communication or Duplex communication

What are the Advantages of Using ASP.NET Web API?

Using ASP.NET Web API has a number of advantages, but core of the advantages are: It works the HTTP way using standard HTTP verbs like  GET ,  POST ,  PUT ,  DELETE , etc. for all CRUD operations Complete support for routing Response generated in JSON or XML format using  MediaTypeFormatter It has the ability to be hosted in IIS as well as self-host outside of IIS Supports Model binding and Validation Support for OData and more....

What is ASP.NET Web API?

ASP.NET Web API is a framework that simplifies building HTTP services for broader range of clients (including browsers as well as mobile devices) on top of .NET Framework. Using ASP.NET Web API, we can create non-SOAP based services like plain XML or JSON strings, etc. with many other advantages including: ·          1 . Create resource-oriented services using the full features of HTTP ·          2. Exposing services to a variety of clients easily like browsers or mobile devices, etc.

What is SOLID Principle in OOPS

  Single Responsibility Principle states that every object should only have one reason to change, i.e. every object should perform one thing only. Open-Closed Principle states that classes should be open for extension and closed for modification. Liskov Substitution Principle states that you should be able to use a derived class in place of a parent class and it must behave in the same manner.   Interface Segregation Principle states that clients should not be forced to depend on interfaces they  do not use. Dependency Inversion Principle helps to decouple your code by ensuring that you depend on abstractions rather than concrete implementations.

Difference Between Singleton and Static class?

Singleton :  1. Singleton class contains both static and non-static members  2. You can create instance of Singleton class.  3. You can implement inheritance.  4. You can clone a singleton class object.  5. Singleton class object creates in Heap memory.   Static Class:     1. Static class contains only static members.   2. You can't create instance of Static class.   3. Once you declare a class as static you can't implement inheritance.   4. You can't clone static class object.   5. Static class object creates in stack memory.

Difference between Delete and Truncate in sql

DELETE 1. DELETE is a DML Command. 2. DELETE statement is executed using a row lock, each row in the table is locked for deletion. 3. We can specify filters in where clause 4. It deletes specified data if where condition exists. 5. Delete activates a trigger because the operation are logged individually. 6. Slower than truncate because, it keeps logs. 7. Rollback is possible. TRUNCATE 1. TRUNCATE is a DDL command. 2. TRUNCATE TABLE always locks the table and page but not each row. 3. Cannot use Where Condition. 4. It Removes all the data. 5. TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. 6. Faster in performance wise, because it doesn't keep any logs. 7. Rollback is not possible. DELETE and TRUNCATE both can be rolled back when used with TRANSACTION. If Transaction is done, means COMMITED, then we can not rollback TRUNCATE command, but we can still rollback DELETE command from LOG files, as DELETE write records them in Log fil...