Skip to main content

Posts

Versioning ASP.NET Web API Services uri based Versioning

I’ve been doing some work with APIs lately and finally had the chance to dig into the ASP.NET Web API a bit more. While it’s technically brand new (released with .NET 4.5 and Visual Studio 2012), the Web API has been around in beta form for quite a bit now. For those of us who have done a fair amount of work with the WCF framework, the Web API is a welcome addition/replacement. Instead of monstrous configuration files and contract-first demands placed on us by WCF, we can now build RESTful web services using a very lightweight and HTTP-focused framework. As I work on designing a new API, one thing that I’m focused on right now is versioning.

In this blog post, I’ll show you how to build uri based versioning for ASP.NET Web API services.

Reference 

https://seroter.wordpress.com/2012/09/25/versioning-asp-net-web-api-services-using-http-headers/

http://www.codeproject.com/Articles/741326/Introduction-to-Web-API-Versioning

http://bitoftech.net/2013/12/16/asp-net-web-api-versioning-strategy/

Recent posts

Compare database schema sql server free tools

Compare database schema sql server free tools
SQL Admin Studio
https://www.simego.com/Install/SQL-Tools

Open DBDiff 0.9

http://opendbiff.codeplex.com/releases/view/72756

Related Urls :

What is best tool to compare two SQL Server databases (schema and data)
http://stackoverflow.com/questions/193438/what-is-a-free-tool-to-compare-two-sql-server-databases

http://stackoverflow.com/questions/685053/what-is-best-tool-to-compare-two-sql-server-databases-schema-and-data

AngularJS Interview Questions and Answers

1) What is Angular.js?

AngularJS is a javascript framework used for creating single web page applications.  It allows you to use HTML as your template language and enables you to extend HTML’s syntax to express your application’s components clearly

2) Explain what are the key features of Angular.js ?

The key features of angular.js are

Scope
Controller
Model
View
Services
Data Binding
Directives
Filters
Testable
3) Explain what is scope in Angular.js ?

Scope refers to the application model, it acts like glue between application controller and the view.  Scopes are arranged in hierarchical structure and impersonate the DOM ( Document Object Model) structure of the application.  It can watch expressions and propagate events.

4) Explain what is services in Angular.js ?

In angular.js services are the singleton objects or functions that are used for carrying out specific tasks.  It holds some business logic and these function can be called as controllers, directive, filters and so on.

5) Ex…

How to send mail asynchronously in asp.net with MailMessage

With Microsoft.NET Framework 2.0 everything is asynchronous and we can send mail also asynchronously. This features is very useful when you send lots of bulk mails like offers , Discounts , Greetings . You don’t have to wait for response from mail server and you can do other task . By using    SmtpClient.SendAsync Method (MailMessage, Object)   you need to do  System.Net.Mail has also added asynchronous support for sending email. To send asynchronously, you need need to Wire up a SendCompleted eventCreate the SendCompleted eventCall SmtpClient.SendAsync
smtpClient.send() will initiate the sending on the main/ui  thread and would block.  smtpClient.SendAsync() will pick a thread from the .NET Thread Pool and execute the method on that thread. So your main UI will not hang or block .
Let's create a simple example to send mail. For sending mail asynchronously you need to create a event handler that will notify that mail successfully sent or some errors occurred during sending mail. Let…

WEB API: PASSING A COMPLEX TYPE IN JSON USING J QUERY

In my  project i wanted to pass a complex type to the Post method of an Web Api controller. The Post itself will be done using JQuery in the JSON format. I noticed that the parameter was always null. After a bit of searching i found the solution

Server Side code 

 public class ValuesController : ApiController
    {

        public class MyComplexType         {             public string Name { get; set; }
            public MyComplexSubType MyComplexSubType { get; set; }         }
        public class MyComplexSubType         {             public int Age { get; set; }         }
        // GET api/<controller>         public IEnumerable<string> Get()         {             return new string[] { "value1", "value2" };         }
        // GET api/<controller>/5         public string Get(int id)         {             return "value";         }
        // POST api/values         public void Post(MyComplexType value)         {
        }       
    …

How to find index of an item in JavaScript Object Array?

Recently while working I came across a scenario. I had to find index of a particular item on given condition from a JavaScript object array. In this post we will see how to find index of object from JavaScript array of object. Let us assume we have a JavaScript array as following,
Related :  Allow only characters in textbox using javascript in asp.net
var studentsArray =[ { "rollnumber": 1,"name": "dj","subject": "physics"}, {"rollnumber": 2,"name": "krishna","subject": "biology"}, {"rollnumber": 3,"name": "amit","subject": "chemistry"}, ]; Now if we have a requirement to select a particular object in the array. Let us assume that we want to find index of student with name Tanmay.
We can do that by iterating through the array and comparing value at the given key. function functiontofindIndexByKeyValue(arraytosearch, key, valuetosearch) {
for (…