Sometimes we need to add Authorization Tokens in Header in HttpClient. This is sample code for adding Authorization .var client = new HttpClient();client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
This code sample will illustrate how we can create Excel file from a data table in c#.You will need to add DocumentFormat.OpenXml and WindowsBase dll to make it work.private static void WriteExcelFile(string outputPath, DataTable table){ using (SpreadsheetDocument document = SpreadsheetDocument.Create(fileToGenerate, SpreadsheetDocumentType.Workbook)) { WorkbookPart workbookPart = document.AddWorkbookPart(); workbookPart.Workbook = new Workbook(); WorksheetPart worksheetPart = workbookPart.AddNewPart<Wor
We can easily configure StyleCop with MSBuild to make warnings appear as errors with the help of StyleCop.MSBuild NuGet package.First go to Package Manager Console and install it with following command. Install-Package StyleCop.MSBuildThen unload your project and open the project file to modify it.Now you have to add "StyleCopTreatErrorsAsWarnings" property inside "PropertyGroup" tag as below.<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"><PropertyGroup> <ErrorT
Dependency Injection allows us to inject objects into a class, instead of constructing them internally. Unity is a dependency injection container that we can use for constructor, property, and method call injections. You can get good idea about dependency injection by reading answers to this stack-overflow question. This tutorial is an step-by-step guide with screen-shots where you can learn how ...
In this tutorial I'm going to illustrate how we can pass complex javascript objects to MVC controller. Here are the Model objects. public class Project { public long ProjectID { get; set; } public string ProjectName { get; set; } } public class Employee { public string Code { get; set; } public string Name { get; set; } } ...
In this post I'm going to illustrate how we can access web service in Android using ksoap2-android project that provides a lightweight and efficient SOAP library for the Android platform.You can download the jar file from following link;http://ksoap2-android.googlecode.com/svn/m2-repo/com/google/code/ksoap2-android/ksoap2-android-assembly/2.5.8/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jarHere is the sample code that illustrate SOAP web service call. I have access a live web service ConvertWeight
In Android we can use HTTP POST request with org.apache.http.client.HttpClient to post data to a URL. This sample project illustrate how we can post data to a URL and get the response.package com.sencide;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;import org.apache.http.Htt
Microsoft SQL Server Management Studio provides integrated environment for accessing, configuring, managing, administering and developing all components of SQL Server. There you can see two authentication modes called "Windows Authentication" and "SQL Server Authentication". The Windows authentication mode only allows you to login/connect to SQL Server with Windows authentication.If you install the
This tutorial discuss how you can enable (Internet Information Service) IIS in Windows 7 or Windows Vista. I have provided screen-shots so that you can easily understand.First go to control panel and select Programs.Then select Turn Windows features on or off.Then select Internet Information
This tutorial explains how we can create simple Web Services using Visual Studio 2008 or Visual Studio 2010.If you are interested in creating web services in java, please follow my postCreate Web Service in Java Using Apache Axis2 and Eclipse1. Create the Web ServiceFirst create new project and select "New ASP.NET Web Service Application" and I'm giving the name "MyFirstWebService" ...
In this post I’m going to describe about a practical use of my previous article JQuery AJAX. Here I’m going to discuss how to validate a form and how to add auto suggests to a form using JQuery and PHP.
You may know that, JQuery is a JavaScript library that we can do smart things using small pease of code. This free and open source JavaScript Library has become the most famous JavaScript Library today because of its Lightweight, Cross-browser and CSS3 Compliant. Using JQuery we can do thing like Document Navigating, DOM Element Selecting, Creating Animations, Event Handling and ...
In this post I’m going to show you how to embed a picture to body of the message in Gmail without attaching. To get this work done you have to enable Image Inserting in Google Labs. Let’s see how we can enable this.First log in to your account and go to Settings as following picture;Then go to ...
In one of my previous article I discussed how we can retrieve data in a SharePoint List Using its Web Services. In this post I’m going to discuss how we can update a SharePoint list using Web Services. Please refer my previous article on "SharePoint List Web Service GetListItems" to learn how to add Web References to your project. Then ...
In this post, I’ going to discuss how we can retrieve data from a SharePoint List using its Web Services. First to know about SharePoint Web Services please refer this. We can user List Web Service which provides methods for working with SharePoint Lists, Content Types, List Items, and Files to read a List. Here we are going to use ...
In this post I’m going to discuss about an easiest way to find GUID of a SharePoint list and a View. If you are using the MOSS 2007 there is straight forward way to get the List GUID, these are the steps.1. Access the list via your browser.2. Go to Settings --> List Settings and right-click on the "Information management ...
Let’s see how we can programmatically add a user to existing SharePoint user group . You can use the following method which has two string parameters, one for group name and other for user login name for get the above task done. public void addUserToGroup(string groupName, string userLoginName){ string strUrl = "http://mysite:5050/"; using (SPSite site = new SPSite(strUrl)) { using ...
In my previous posts on "Working With SharePoint List" I have discussed how we can Read, Add and Update SharePoint List. If you have to add new Item to a list which has lookup column, you have to follow a different procedure.If you look at the following figure, you can easily understand what I'm going to do. I'm going to ...
In this post I’m going to describe how you can programmatically add a view to SharePoint list or Document Library. You can get this work done by using SPViewCollection.Add Method (Microsoft.SharePoint), here is a sample code, public void createListView() { SPSite site = new SPSite("http://merdev-moss:5050/testsara"); SPWeb web = site.OpenWeb(); SPList list = web.Lists["Tasks"]; SPViewCollection allviews = list.Views; string viewName = ...
In this post I'm going to discuss how you can add a permission level (Read, Contribute, Full Control, etc) to a SharePoint user group. Here is a sample code, public void addPermissionToGroup() { SPSite site = new SPSite("http://mysite:5050/"); SPWeb spWeb = site.OpenWeb(); string permissionName = "Read"; string groupName = "Project Manager"; try { spWeb.AllowUnsafeUpdates = true; SPRoleAssignment roleAssignment = new ...