asp.net-web-api

Unable to get Access token and Refresh token

情到浓时终转凉″ 提交于 2020-02-01 07:29:19
问题 All ClientID, ClientSecret & RedirectURI placed in the web.config . <appSettings> <add key="redirectURI" value="http://localhost:55593/oauthplayground" /> <add key="clientId" value="uX4YpHHNm****ltekoG" /> <add key="clientSecret" value="K5cSv3izT1GZ9PXnaWWfRWbTv10*****O3JkYFMlWMF3FhBtjyk0FqJduGJZSAL7B1DngJyxgX3KKNSD0Bqdv" /> </appSettings> Now from here I got the authentication code. static string redirectURI = ConfigurationManager.AppSettings["redirectURI"]; static string clientID =

Unable to get Access token and Refresh token

a 夏天 提交于 2020-02-01 07:28:25
问题 All ClientID, ClientSecret & RedirectURI placed in the web.config . <appSettings> <add key="redirectURI" value="http://localhost:55593/oauthplayground" /> <add key="clientId" value="uX4YpHHNm****ltekoG" /> <add key="clientSecret" value="K5cSv3izT1GZ9PXnaWWfRWbTv10*****O3JkYFMlWMF3FhBtjyk0FqJduGJZSAL7B1DngJyxgX3KKNSD0Bqdv" /> </appSettings> Now from here I got the authentication code. static string redirectURI = ConfigurationManager.AppSettings["redirectURI"]; static string clientID =

Prevent integer values to set boolean parameter in ASP.NET Web API model binding?

纵然是瞬间 提交于 2020-02-01 05:06:39
问题 I am developing an ASP.NET Web API in which a method takes below model as an input parameter public InputModel { int Id {get; set;} bool? IsTrue {get; set;} } It works with true and false value. I tried to check how it behaves for non-boolean values. So I provided inputs and got some results isTrue = 0 -> model set to false isTrue = 1 -> model set to true isTrue = 2 -> model set to true isTrue = -1 -> model set to true This is something that I didn't expect. The model is set to true for all

MVC WebAPI authentication from Windows Forms

爱⌒轻易说出口 提交于 2020-01-31 07:03:25
问题 I am attempting to make a Windows Forms application that plugs into some services exposed by ASP.NET MVC WebAPI, but am having a great deal of trouble with the authentication/login part. I cannot seem to find an example that just demonstrates how to do this from Windows Forms, everything I find seems to be very convoluted and includes a lot of very deep plumbing, or seems targeted to other ASP.NET websites, and not windows forms. Is there something I am missing? Is this just not possible? Or

How can I combine a MVC4 site and a WebAPI site under the same IIS website?

无人久伴 提交于 2020-01-31 05:49:04
问题 I have a project (named Product.Api ) that has some controllers used for our WebAPI site. The controllers are in a namespace Product.Api.Controllers . The project also has some other helper stuff as well. This is compiled into a library. I also have another regular ASP.NET MVC4 website named Product.Web . This has Controllers (under the namespace Product.Web.Controllers ), Models and Views (in its corresponding folders). It also has a Global.asax.cs which has the routing information. When the

How can I combine a MVC4 site and a WebAPI site under the same IIS website?

放肆的年华 提交于 2020-01-31 05:48:46
问题 I have a project (named Product.Api ) that has some controllers used for our WebAPI site. The controllers are in a namespace Product.Api.Controllers . The project also has some other helper stuff as well. This is compiled into a library. I also have another regular ASP.NET MVC4 website named Product.Web . This has Controllers (under the namespace Product.Web.Controllers ), Models and Views (in its corresponding folders). It also has a Global.asax.cs which has the routing information. When the

Angular.js $resource with ASP.Net webapi?

岁酱吖の 提交于 2020-01-30 09:10:43
问题 I have a simple ASP.Net WebAPI service that assigns a static variable on POST/PUT and returns the value on GET: private static State Repo = null; public State Get() { return Repo; } public void Post(State value) { Repo = value; } public void Put(State value) { Repo = value; } And I have an angular-resource defined like so: var stateService = angular.module('StateService', ['ngResource']); stateService.factory('State', function ($resource) { return $resource('http://localhost:8080/API/State');

How to send Timespan to WebAPI from Javascript

纵饮孤独 提交于 2020-01-30 05:28:08
问题 I have two moment dates and am calculating the duration by doing the diff between both. How can I post the duration to the WebAPI controller so that it is automatically deserialize to a C# TimeSpan? When I post "P2DT00H" it will deserialize properly to a TimeSpan but how can I get that format from a moment duration? 回答1: Calculate the duration as described in this answer Get the time difference between two datetimes Define an endpoint like this: public IHttpActionResult Post([FromBody]

Pagination In WebAPI

≡放荡痞女 提交于 2020-01-30 03:31:08
问题 Currently I have following way of providing pagination for every entity/resource for a set of APIs: public IHttpActionResult GetPageUsers(int startindex, int size, string sortby = "Username", string order = "DESC") { if (!order.Equals("ASC") && !order.Equals("DESC")) return BadRequest("Order Has To Be DESC or ASC"); if (!new string[] { "username", "name" }.Contains(sortby.ToLower())) return BadRequest("Not A Valid Sorting Column"); return Ok(new { records = Mapper.Map<List<User>, List

Web Api won't download file using jQuery Ajax and Basic Auth

徘徊边缘 提交于 2020-01-29 05:37:04
问题 I am using the ASP.NET Web API to build a prototype of a web service (and site) which has a method to download a file. When the user on the front-end presses the export button a jQuery ajax GET request is made and received by the controller which on it's turn calls the method named Excel (shown below). The method runs without any problem and finishes. When I look in Chrome at the header (see https://skydrive.live.com/redir?resid=2D85E5C937AC2BF9!77093) it receives the response with (as far as