asp.net-web-api

how to get data of php Web api json from server to using angularJs.?

六月ゝ 毕业季﹏ 提交于 2019-12-25 06:27:07
问题 When i am save this json in my local computer and use it in my angularjs script. It's work fine. But when i am using direct server to this it is not working why.? What are missing in my script.? my Json File > http://deals.ownaroof.com/api/webservices/locations_list.json Html > <div ng-controller='prefferedCtrl'>{{locations}}</div> Script > (function(){ angular.module('myapp',['ngRoute']) //afactory to consume webservices and return data to controllers. .service('webServices',['$http'

Why does oData V4 not order on datetime?

送分小仙女□ 提交于 2019-12-25 06:19:05
问题 I've created a oData V4 endpoint with Web API 2.2 and Entity Framework. The model that is expose looks like the following model: public class Items { public int Id { get; set; } public string Name { get; set; } public DateTime CreatedOn { get; set; } } When I go to the URL: /odata/Items it works like a charm. But when I go to the URL: /odata/Items?$orderby=CreatedOn I get the following error: 'The specified type member 'Kind' is not supported in LINQ to Entities. Only initializers, entity

JSON to .Net Epoch date conversion

余生长醉 提交于 2019-12-25 05:22:30
问题 I have a simple WebAPI project. I am passing JSON date in Epoch format "pickupBefore":"/Date(1485360480-0800)/". When .Net catches it the DateTime shows year 1970. It is suppose to be January 25, 2017. What should I do to get it in real time? In my .Net application, I am catching the date as DateTime. Behind the scene the DateTime structure get filled with the date from 1970. I was looking for something in that structure that will help me to convert it to real time DateTime. I did looked at

JSON to .Net Epoch date conversion

雨燕双飞 提交于 2019-12-25 05:22:06
问题 I have a simple WebAPI project. I am passing JSON date in Epoch format "pickupBefore":"/Date(1485360480-0800)/". When .Net catches it the DateTime shows year 1970. It is suppose to be January 25, 2017. What should I do to get it in real time? In my .Net application, I am catching the date as DateTime. Behind the scene the DateTime structure get filled with the date from 1970. I was looking for something in that structure that will help me to convert it to real time DateTime. I did looked at

POST to ASP.NET WebAPI using Fiddler2

岁酱吖の 提交于 2019-12-25 05:21:42
问题 I have a class that models exactly the entity I have in the database. I have a stored procedure that takes in parameters for a new row and returns all the settings in the table which in turn populates my repository. I am able to see the results of GET, PUT and DELETE in the List of type Setting that is in memory. I am noticing first that even when I close Visual Studio and reopen and run the project, sometimes, the List is still in the state it was before. It is not repopulating from the

ASP.NET Web API how to authenticate user

核能气质少年 提交于 2019-12-25 05:04:07
问题 I'm trying to create a simple user authentication function but I just can't get it to work. Here is the code I'm working on: public class LoginController : ApiController { private void SetPrincipal(IPrincipal principal) { Thread.CurrentPrincipal = principal; if (HttpContext.Current != null) { HttpContext.Current.User = principal; } } public bool Login(string token) { //Check token if (.....) { //Authenticate user var identity = new GenericIdentity("Test user"); SetPrincipal(new

Best practice to send a lot of files (images) from your device to your server

妖精的绣舞 提交于 2019-12-25 04:57:10
问题 I have a list of files to send from my device to my server. List<myFiles> list = new List<myFiles>() { "[long list of files...]" }; For that I want to create a list of tasks: for each file I should invoke a function that sends to my webapi that file via PUT public async Task<bool> UploadPhoto(byte[] photoBytes, int PropertyId, string fileName) { bool rtn = false; if (CrossConnectivity.Current.IsConnected) { var content = new MultipartFormDataContent(); var fileContent = new ByteArrayContent

Is it possible to allow user to edit and save html template in angularjs application

天大地大妈咪最大 提交于 2019-12-25 04:55:18
问题 I have an traditional asp.net application which reads HTML template and renders it inside div control. Using bootstrap xeditable user can edit certain parts of the template (only text). This template is later used to send emails. This functionality is working fine. Now I am rewriting this application using AngularJs and WebApi. I am using angular route to route to different pages (plain html) of the application. I am able to load the template using directive. now I want to allow user to edit

ASP.NET MVC Controller cannot return HttpResponseMessage correctly with streamed content

好久不见. 提交于 2019-12-25 04:46:10
问题 Just as the title says I am not getting the MVC Controller to return HttpResponseMessage correctly. [HttpGet] [AllowAnonymous] public HttpResponseMessage GetDataAsJsonStream() { object returnObj = new { Name = "Alice", Age = 23, Pets = new List<string> { "Fido", "Polly", "Spot" } }; var response = Request.CreateResponse(HttpStatusCode.OK); var stream = new MemoryStream().SerializeJson(returnObj); stream.Position = 0; response.Content = new StreamContent(stream); response.Content.Headers

How do I specify the class instance I want my Controller's constructor to receive (when working with Web API, DI, and Castle Windsor)?

不想你离开。 提交于 2019-12-25 04:33:31
问题 Perhaps my questions here and here are not clear enough, so I'll try to decrease the verbosity while not reducing the clarity. Say my Controller uses DI (you can verbalize it "in your head" - you don't have to utter it out loud); so it could look like this: private readonly IDepartmentRepository _deptsRepository; public DepartmentsController(IDepartmentRepository deptsRepository) { if (deptsRepository == null) { throw new ArgumentNullException("deptsRepository is null"); } _deptsRepository =