I looked at many solution for basic authentication but i failed to understand. So please help me to solve this problem. Here is my code which call wcf service
$.ajax({
url: "Ajaxservices/Activity.svc/getMaterials",
dataType: 'json',
contentType: "application/json",
data: JSON.stringify({ query: query,"collegId":parseInt($('#CollegID').val()) }),
type: 'POST',
success: function (response) {
materials = [];
map = {};
$.each(response.d, function (i, material) {
map[material.ItemName] = material;
materials.push(material.ItemName);
});
process(materials);
}
});
and this wcf service
#region GetMaterials
[OperationContract]
[WebInvoke(Method="POST",BodyStyle=WebMessageBodyStyle.WrappedRequest,RequestFormat = WebMessageFormat.Json,ResponseFormat = WebMessageFormat.Json)]
public List<HMSEntities.Materials> getMaterials(string query, int collegId)
{
try
{
List<HMSEntities.Materials> materialList = activityDal.getMaterials(query, collegId);
return materialList;
}
catch (Exception ex)
{
HMS.BasePage objPage = new BasePage();
string msg = objPage.GetErrorInformation(ex);
objPage.Log4Error(Convert.ToInt32(System.Web.HttpContext.Current.Session["HospID"]), msg);
throw ex;
}
}
#endregion