Category: WEBAPI

ConnectionStrings – (Localdb)\v11.0

[cc] <add name=”SimpleSecurityConnection1″ connectionString=”Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-RefApp-20131021102513.mdf;Initial Catalog=aspnet-RefApp-20131021102513;Integrated Security=True” providerName=”System.Data.SqlClient” /> [/cc]   Favorite

Read more

ASP.NET Web API to return JSON or XML data

Add the below code app_start event in global.asax file.In API Url add the query string. //json GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add( new QueryStringMapping(“type”, “json”, new MediaTypeHeaderValue(“application/json”))); //xml GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add( new QueryStringMapping(“type”, “xml”, new MediaTypeHeaderValue(“application/xml”))); eg: for xml : http://localhost:49533/api/books?type=xml for json: http://localhost:49533/api/books?type=json Favorite

Read more