asp.net-web-api

C# Download file from webservice

末鹿安然 提交于 2020-07-15 08:21:20
问题 I have a web service, like this example for downloading a zip file from the server. When i open the URL through web browsers,I can download the zip file correctly. The problem is when I try to download the zip file through my desktop application. I use the following code to download: WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);

C# Download file from webservice

丶灬走出姿态 提交于 2020-07-15 08:21:13
问题 I have a web service, like this example for downloading a zip file from the server. When i open the URL through web browsers,I can download the zip file correctly. The problem is when I try to download the zip file through my desktop application. I use the following code to download: WebClient webClient = new WebClient(); webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);

EF6 Automapper Inheritance/Abstract Class Errors

Deadly 提交于 2020-07-10 11:33:06
问题 I'm building a .NET Web API using Entity Framework 6 with AutoMapper to map entities to DTOs. When I try to introduce an TPH (table per hierarchy) with an abstract base class, I get a very long and very useless (to me at least) error. The error is below, I'm not sure what the actual error is. I've tried Googling various sections of it to no avail. This is my mapping: Mapper.CreateMap<ParentClass, ParentClassDTO>() .Include<ClassA, ClassADTO>() .Include<ClassB, ClassBDTO>(); Mapper.CreateMap

EF6 Automapper Inheritance/Abstract Class Errors

妖精的绣舞 提交于 2020-07-10 11:32:58
问题 I'm building a .NET Web API using Entity Framework 6 with AutoMapper to map entities to DTOs. When I try to introduce an TPH (table per hierarchy) with an abstract base class, I get a very long and very useless (to me at least) error. The error is below, I'm not sure what the actual error is. I've tried Googling various sections of it to no avail. This is my mapping: Mapper.CreateMap<ParentClass, ParentClassDTO>() .Include<ClassA, ClassADTO>() .Include<ClassB, ClassBDTO>(); Mapper.CreateMap

jQuery Datatables AJAX request not hitting Web API correctly

江枫思渺然 提交于 2020-07-09 09:29:16
问题 I am trying to integrate ASP.NET Web API 2 with jQuery Datatables 1.10.7 . I want to use Server Side processing in my Datatables, so I am used the Nuget package DataTables.AspNet.WebApi2 Here is my javascript <script> $(document).ready(function () { $('#example').dataTable({ "serverSide": true, "ajax": "/api/StudentsBasicInfo/GetPaginatedStudentsList2", columns: [ { name: 'FirstName', data: 'FirstName', title: "First Name", sortable: false, searchable: false }, { name: 'LastName', data:

jQuery Datatables AJAX request not hitting Web API correctly

人走茶凉 提交于 2020-07-09 09:27:12
问题 I am trying to integrate ASP.NET Web API 2 with jQuery Datatables 1.10.7 . I want to use Server Side processing in my Datatables, so I am used the Nuget package DataTables.AspNet.WebApi2 Here is my javascript <script> $(document).ready(function () { $('#example').dataTable({ "serverSide": true, "ajax": "/api/StudentsBasicInfo/GetPaginatedStudentsList2", columns: [ { name: 'FirstName', data: 'FirstName', title: "First Name", sortable: false, searchable: false }, { name: 'LastName', data:

'ObjectContent`1': Failed to serialize the response from DbSet

僤鯓⒐⒋嵵緔 提交于 2020-07-08 03:38:12
问题 I have the following controller in TabletController.cs file: public class TabletController : ApiController { public IQueryable Get(int c_id) { using (EMSMVCEntities entities = new EMSMVCEntities()) { return entities.Calls.Where(e => e.call_id == c_id); } } } I'm trying to call: http://localhost:53366/api/Tablet/157 But I get the following error: Call is dDbSet Also, I need to get the results of the table's fields in json format. I tried to serialize it in JSON, but I get the same error.

How do I add a foreign key to Identity user in EF Core?

女生的网名这么多〃 提交于 2020-07-05 03:18:26
问题 Let's say I have a Todo model with a corresponding Todo table ( DbSet<Todo> ) in an EF-generated database. The table will store a todo item per row. Each user (in an ASP.NET Core Identity + IdentityServer app) will be associated with multiple todo items (one-to-many, a user can have multiple todo items). The way I'd do it is to add a UserId foreign key to the Todo model that represents the user that owns the todo item . How would I do that with EF Core while utilizing the classes proved by

Customizing the AuthenticationStateProvider in Blazor Server App with Jwt Token Authentication

做~自己de王妃 提交于 2020-07-02 03:05:39
问题 I've noticed that many developers subclass the AuthenticationStateProvider both in Blazor Server App and Blazor WebAssembly App wrongly, and more imprtantly for the wrong reasons. How to do it correctly and when ? 回答1: First off, you do not subclass the AuthenticationStateProvider for the sole purpose of adding claims to the ClaimPrincipal object. Generally speaking, claims are added after a user has been authenticated, and if you need to inspect those claims and tranform them, it should be

Customizing the AuthenticationStateProvider in Blazor Server App with Jwt Token Authentication

假装没事ソ 提交于 2020-07-02 03:05:38
问题 I've noticed that many developers subclass the AuthenticationStateProvider both in Blazor Server App and Blazor WebAssembly App wrongly, and more imprtantly for the wrong reasons. How to do it correctly and when ? 回答1: First off, you do not subclass the AuthenticationStateProvider for the sole purpose of adding claims to the ClaimPrincipal object. Generally speaking, claims are added after a user has been authenticated, and if you need to inspect those claims and tranform them, it should be