asp.net-web-api2

Web Api .net framework 4.6.1 and identityServer4

六月ゝ 毕业季﹏ 提交于 2020-05-13 18:13:27
问题 Web Api .net framework I have an authentication service done with IdentityServer4 .net core 1.1. The client settings are as follows: new Client { ClientId = "client", AllowedGrantTypes = GrantTypes.ClientCredentials, ClientSecrets = { new Secret("secret".Sha256()) }, AllowedScopes = { "api1" } }, // resource owner password grant client new Client { ClientId = "ro.client", AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, ClientSecrets = { new Secret("secret".Sha256()) }, AllowedScopes = {

Web Api .net framework 4.6.1 and identityServer4

懵懂的女人 提交于 2020-05-13 18:12:39
问题 Web Api .net framework I have an authentication service done with IdentityServer4 .net core 1.1. The client settings are as follows: new Client { ClientId = "client", AllowedGrantTypes = GrantTypes.ClientCredentials, ClientSecrets = { new Secret("secret".Sha256()) }, AllowedScopes = { "api1" } }, // resource owner password grant client new Client { ClientId = "ro.client", AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, ClientSecrets = { new Secret("secret".Sha256()) }, AllowedScopes = {

Sliding Session on Web API Request

给你一囗甜甜゛ 提交于 2020-05-10 06:47:09
问题 UPDATE: it appears it is trying to write the new cookie header in ApplyResponseGrantAsync but can't because it's throwing an exception that the headers are already sent. UPDATE: to be clearer. How do I get the Set-Cookie header added to the XHR response during a Web API request? TL;DR; The issue is that the application is authenticated with MVC, but makes heavy use of Web API. The Web API requests do not slide the session even though they use the Authentication attribute - almost certainly

swagger error: Conflicting schemaIds: Duplicate schemaIds detected for types A and B

馋奶兔 提交于 2020-05-09 20:02:10
问题 Using Web API and using swashbuckle to generate swagger documentation, I defined two different classes with the same name in two different namespaces. when I open swagger page in my browser it says Conflicting schemaIds: Duplicate schemaIds detected for types A and B. See the config setting - "UseFullTypeNameInSchemaIds" for a potential workaround full message: 500 : {"Message":"An error has occurred.","ExceptionMessage":"Conflicting schemaIds: Duplicate schemaIds detected for types A and B.

RoutePrefix vs Route

♀尐吖头ヾ 提交于 2020-05-09 19:28:25
问题 I understand that RoutePrefix doesn't add a route to the routing table by itself. On your actions you need to have a Route attribute declared. I am having a hard time finding an authoritative blog/msdn page/ something that states why by defalut RoutePrefix doesn't add a route to the routing table. Does anyone have an authoritative post that does contain this to be the case, and if so will you let me know whom it is. Thank you very much. Edit To Clarify my question DOESN'T WORK [RoutePrefix(

RoutePrefix vs Route

梦想与她 提交于 2020-05-09 19:28:14
问题 I understand that RoutePrefix doesn't add a route to the routing table by itself. On your actions you need to have a Route attribute declared. I am having a hard time finding an authoritative blog/msdn page/ something that states why by defalut RoutePrefix doesn't add a route to the routing table. Does anyone have an authoritative post that does contain this to be the case, and if so will you let me know whom it is. Thank you very much. Edit To Clarify my question DOESN'T WORK [RoutePrefix(

Web Api Routing : Multiple controller types were found that match the URL

社会主义新天地 提交于 2020-04-30 16:35:49
问题 I'm getting,"Multiple controller types were found that match the URL", Error while performing postman operation for the below API Calls. Can someone help me figuring out the attribute mapping for the same. What I think is resolver considering the "respond" as the name of the Book. Thanks In Advance Code Snippet : public class BookApiController : ApiController { [HttpGet] [Route("api/v1/books/{bookName}")] public async Task<HttpResponseMessage> Get(string bookName){ /* Code Here */ } } public

Web Api Routing : Multiple controller types were found that match the URL

北城余情 提交于 2020-04-30 16:33:12
问题 I'm getting,"Multiple controller types were found that match the URL", Error while performing postman operation for the below API Calls. Can someone help me figuring out the attribute mapping for the same. What I think is resolver considering the "respond" as the name of the Book. Thanks In Advance Code Snippet : public class BookApiController : ApiController { [HttpGet] [Route("api/v1/books/{bookName}")] public async Task<HttpResponseMessage> Get(string bookName){ /* Code Here */ } } public

Error posting JSON to Web API 2 : The request entity's media type 'text/plain' is not supported for this resource

夙愿已清 提交于 2020-03-18 03:46:38
问题 I have this class : public class MyClass { public MyClass() { Secret = "Don't tell me"; } public string Name { get; set; } public int Age { get; set; } public string Description { get; set; } private string Secret { get; set; } } And this WEB API method : // POST api/fixture public HttpResponseMessage Post(MyClass value) { return new HttpResponseMessage(HttpStatusCode.Created); } I've set Web API to return JSON instead of XML and I haven't done any other change to the default config. I'm

PutAsync doesn't send request to web api, but fiddler works fine

…衆ロ難τιáo~ 提交于 2020-03-02 04:40:06
问题 I have been trying to figure out what is going wrong for a few hours now and i just can't find what is going wrong. Via the Mvc application the put method doesn't get hit, the request doesn't happen. But when i test it in fiddler the PutMethod in the api works. Hopefully someone can clear things up for me. Also pointers for a better structure or some good documentation are welcome . public void UpdateWerknemerCompetentieDetail(int wnID, int WNC, CompetentieWerknemerDetail detail) { using