asp.net-web-api

Http Get Request not getting any data

谁说我不能喝 提交于 2021-01-29 08:00:37
问题 I have my Web Api on a production server online and working well in postman and in Xamarin forms so far until I needed to do a Get Request and does not return any data. Infact it stops at the GetAsStringAsync line and does not continue. Instead, it jumps out of the method and then nothing more. Does any one know what the problem could be? I have checked and made sure my Internet is working and the Uri too. This is where I am doing my Get in Xamarin forms: public async Task<List<OfferModel>>

Calculated Properties in Odata v4 and Entity Framework

末鹿安然 提交于 2021-01-29 04:24:34
问题 Im working on a .Net Web Api 2.2 project and I'm using Odata v4 and Entity Framework code first. I need to have a calculated property in a Model which is not to be saved in Database. I have tried [notmapped] attribute. But it hides the property in Odata $medadata. How can I overcome this issue? 回答1: You can manually add this property into model. You can refer to the sample codes in: How to get Web API OData v4 to use DateTime Hope it can help. 来源: https://stackoverflow.com/questions/31191013

Owin selfhost: using netsh to add an urlAcl seems to cause 503

本小妞迷上赌 提交于 2021-01-29 03:08:09
问题 I have a owin selfhost of a simple WebApi running as a windows service. After creating/installing certificates to aproach this WebApi through https, I got the certificate working but stayed stuck with a return code of 503. It seemed not a certificate problem, the browser does not complain anymore and shows a closed lock as intended. I changed the service account during the certificate installation, so to test if that was the problem I changed the listening address back to http. It worked fine

Unable to access swagger despite cors enabled Asp.NET WebAPI

隐身守侯 提交于 2021-01-29 02:48:28
问题 I have a WebAPI - .NET framework 4.6.2 I am getting below error on the accessing the webapi via swagger: Can't read from server. It may not have the appropriate access-control-origin settings. I have already CORS in my code I wonder what is going worng WebAPIConfig.cs public static class WebApiConfig { public static void Register(HttpConfiguration config) { config.EnableCors(); } } GlobalAsax.cs protected void Application_Start() { RouteTable.Routes.MapOwinPath("swagger", app => { app

How to ensure only one instance of IHostedService is running within a .NET core 2.2 Web API

北城以北 提交于 2021-01-28 21:02:36
问题 I have a .NET Core 2.2 web API that can be scaled out to several instances based on demand. This API has a background service (IHostedService) that should only run on one of the instances at a time. Is there a common approach or design pattern to ensure this service is only running on one instance at any given point in time? 回答1: The ability to include a hosted service along with the actual application is just like anything else in Core. You can use all of MVC, API and Razor Pages, all in the

How to ensure only one instance of IHostedService is running within a .NET core 2.2 Web API

怎甘沉沦 提交于 2021-01-28 20:40:29
问题 I have a .NET Core 2.2 web API that can be scaled out to several instances based on demand. This API has a background service (IHostedService) that should only run on one of the instances at a time. Is there a common approach or design pattern to ensure this service is only running on one instance at any given point in time? 回答1: The ability to include a hosted service along with the actual application is just like anything else in Core. You can use all of MVC, API and Razor Pages, all in the

A route named 'DefaultApi' is already in the route collection error

混江龙づ霸主 提交于 2021-01-28 20:13:50
问题 Despite trying the different solutions available in Stack Overflow, I can't resolve this problem. I have tried: Deleting all dll in bin folder of the project. Cleaning/Rebuilding Renaming the project. I tried verifying in one global.asax but found no duplicate.And I don't have an AreaRegistration.cs file. My code: RouteConfig.cs: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using System.Web.Http; namespace

Unable to update the specified properties for on-premises mastered Directory Sync objects or objects currently undergoing migration

ぃ、小莉子 提交于 2021-01-28 18:53:25
问题 Issue with adding Member to group in Azure AD, getting this error message: Unable to update the specified properties for on-premises mastered Directory Sync objects or objects currently undergoing migration I am trying to add existing member of azure AD to a existing group,But I am getting response as "Bad Request". For some of the calls updateasync worked fine but member not added to group. I have provided my code that I am trying with the error I am getting below.Kindly suggest if any one

Web API suddenly returns 403 forbidden after a few successfull requests

只谈情不闲聊 提交于 2021-01-28 18:28:58
问题 I've been working on an ionic application in combination with an ASP.NET Web API. I'm using that API for all the data transfer. I have been experiencing a problem: after a few successful requests, the API suddenly returns 403 forbidden. It seems like the API has a limitation or something, because it happens when I do multiple requests in a really short time. The strange thing about this problem is that if I run the Web API locally it works perfectly fine, but if I host it on an external IIS

which http methods allowed in “*” when enabling CORS in web api

北战南征 提交于 2021-01-28 12:40:28
问题 I have implemented CORS in web API by using Cors library. [EnableCors(origins: "*", headers: "*", methods: "*")] and in webapi config file config.EnableCors(); I called api using POST method, still I was getting error in console i:e No 'Access-Control-Allow-Origin' header is present on the requested resource. Then I changed [EnableCors(origins: "*", headers: "*", methods: "*")] To [EnableCors(origins: "*", headers: "*", methods: "GET, POST, PUT, DELETE, OPTIONS")] Then its started working, my