Search Posts

Category: asp.net-web-api2

How to pass DateTime from Angular JS to HTTP GET WEB API

how to How to pass DateTime from Angular JS to HTTP GET WEB API I have Date Field and Time Field in HTML. I want to pass Datetime from Angular JS to WEB API in HTTP GET Request but I am unable to do so. HTML <label>Appointment Start Date</label> <p class=”input-group”> <input type=”text” class=”form-control” uib-datepicker-popup=”dd.MM.yyyy” ng-model=”empappt.appstart” is-open=”popup1.opened” show-button-bar=”false” /> <span class=”input-group-btn”> <button type=”button” class=”btn btn-default” ng-click=”open1()”><i class=”glyphicon glyphicon-calendar”></i></button> </span> </p> <label>Appointment Start Time</label> <input type=”time” […]

Is it safe to store token in browser local storage after web api authentication

I am building angular js 1.X application using Asp.net Web API 2 for backend. In web API 2 i can easily get Token by posting my credentials on token end point (ApplicationOAuthProvider) . Now as angular JS is client side so i need a place on client side to save this token so that i can send this token in all subsequent HTTP calls to validate client . For this i am have stored my […]

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’); fileInput.click(); 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 () […]