Search Posts


URL length exceeding when using kendo grid

When I am filtering kendo grid columns, the filters are sending as a query string to the API and the url length is exceeding the limit. I don’t want to increase the limit. So I am trying the http POST method for getting the data. Using OData with WEBAPI at the server side. We have a custom post action in the oDataController //My odata controller HTTP POST method and it is exposed in model configuration […]

Upload file and form data to server using AngularJS and Web API

I am trying to upload file and form data to server using Angular and Web API.I am using the following code. Service: App.factory(‘myService’, [‘$http’, function ($http) { return { uploadFile: function (url, file) { return $http({ url: url, method: ‘POST’, data: file, headers: { ‘Content-Type’: undefined }, transformRequest: angular.identity }); }, otherFunctionHere: function (url, stuff) { return $http.get(url); } }; }]); Controller $scope.uploadFile = function() { var fileInput = document.getElementById(‘fileInput’);; if(fileInput.files.length === 0) return; […]

Not receiving content headers from Web API to Angular

I have a Web API that I want to return a file and the file details. HttpResponseMessage result = Request.CreateResponse(HttpStatusCode.OK); var file = new FileStream(filePath, FileMode.Open, FileAccess.Read); result.Content = new StreamContent(file); result.Headers.Add(“filename”, “MyFile”); return result; Within Angular I do the following: $http.get(url).then(function(response) { console.log(response.headers()); }); The resposnse.headers() does not contain my header record. What am I missing? I’ve looked at other examples online and they are like this. Thanks Source: AngularJS

SignalR web api Bearer token authorization using factory method in angularjs javascript

I am newbiee to SignalR. I am have created a factory method in angular js to invoke method on server side. app.factory(‘TranSteam’, [‘$rootScope’, ‘AuthenticationService’, function ($rootScope, AuthenticationService) { ‘use strict’; var accesstoken = AuthenticationService.getTokenInfo().accessToken; var conn = $.hubConnection(‘http://localhost:1400’); var transHubProxy = conn.createHubProxy(‘TransactionHub’); conn.qs = { ‘token’: accesstoken }; return { on: function (eventName, callback) { transHubProxy.on(eventName, function (trans) { var args = arguments; $rootScope.$apply(function () { callback.apply(transHubProxy, args); }); }); conn.start({ withCredentials: false }).done(function () […]