asp.net-web-api

Knockout.js validation using extenders - prevent validation on load

别等时光非礼了梦想. 提交于 2020-01-24 04:16:25
问题 I have implemented a very basic required validation on "first name" largely based on the example suggested on knockout website (http://knockoutjs.com/documentation/extenders.html) - Live example 2: Adding validation to an observable. My problem is that I don't want the validation to fire when the form is first loaded. Below is my code <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title> <link href="Style.css" rel="stylesheet" /> </head> <body> <p data-bind=

How do I set the WWW-Authentication header in an IAuthenticationFilter implementation?

社会主义新天地 提交于 2020-01-24 04:11:25
问题 I'm implementing basic authentication using MVC5's IAuthenticationFilter interface. My understanding is that this is now the preferred approach instead of using a DelegatingHandler. I've got it working but the www-authenticate header is not being returned in the response. This is my implementation of ChallengeAsync: public async Task ChallengeAsync(HttpAuthenticationChallengeContext context, CancellationToken cancellationToken) { var result = await context.Result.ExecuteAsync

How To Deploy Angular And .NET Core Web API On IIS?

荒凉一梦 提交于 2020-01-24 03:29:14
问题 We have two web sites on IIS for both angular_client and web_api, the hosting bundle is installed and the permission to users such as IUSR, Network, Network Service and Everyone, is already granted. The navigation to each site seperately works, i.e in the API, the call http://localhost:51975/api/user, results in list of all users. The problem is that Angular login page fails to communicate with the API to authenticate users: OPTIONS http://localhost:51975/api/user/authenticate net::ERR

Problems with Model binding and validation attributes with asp.net Web API

本秂侑毒 提交于 2020-01-23 17:55:26
问题 I am writing a Web API with ASP.NET Web API, and make use of the following View Model. I seem to be having a problem with the data binding when there are two validation attributes on a particular property (i.e. [Required] and [StringLength(10)]). When posting a JSON value from a client to a controller action of the form: // POST api/list public void Post([FromBody] TaskViewModel taskVM) I observe the following: If I remove one of the multiple attributes everything is bound OK; If I leave in

An API version is required, but was not specified. webapi

99封情书 提交于 2020-01-23 17:01:52
问题 var constraintResolver = new DefaultInlineConstraintResolver() { ConstraintMap = { ["apiVersion"] = typeof( ApiVersionRouteConstraint ) } }; config.MapHttpAttributeRoutes(constraintResolver); config.AddApiVersioning(o => o.AssumeDefaultVersionWhenUnspecified = true); [ApiVersion("2.05")] [RoutePrefix("api/v{version:apiVersion}/ger")] public class caGerController [Route("~/api/ger/getDetail")] [Route("getDetail")] GetGerData [ApiVersion("1")] [RoutePrefix("api/v{version:apiVersion}/gerDetail")

WebApi OData v4 ComlexType cannot have an EntityType

徘徊边缘 提交于 2020-01-23 11:22:08
问题 We were using WebApi OData v 3 and had a couple ComplexType entities defined in the entity data model that contained EntitySet entities. When moving to OData v 4 and upon doing the modelBulder.GetEdmModel() step we get an InvalidOperationException "The complex type 'Foo' refers to the entity 'Bar' through the property 'Bar'." I look at the spec and see a thing called an "abstract entity type" that is a type that holds entity types. I don't see that in the WebApi OData code so I hope that all

WebApi OData v4 ComlexType cannot have an EntityType

社会主义新天地 提交于 2020-01-23 11:21:06
问题 We were using WebApi OData v 3 and had a couple ComplexType entities defined in the entity data model that contained EntitySet entities. When moving to OData v 4 and upon doing the modelBulder.GetEdmModel() step we get an InvalidOperationException "The complex type 'Foo' refers to the entity 'Bar' through the property 'Bar'." I look at the spec and see a thing called an "abstract entity type" that is a type that holds entity types. I don't see that in the WebApi OData code so I hope that all

Inject IOwinContext with Web API and Ninject

萝らか妹 提交于 2020-01-23 05:48:08
问题 Using Web API 2 and OWIN hosting with Ninject. I would like to inject the current IOwinContext into certain services (so I can get at the Request to get the principal to do some data filtering). With Web Hosting I would, in the old days, simply have used HttpContext.Current but that is not an option with OWIN hosting (and good riddance). This SO question explains how to do it with Autofac. Essentially, you create a Dependency Scope and then, on each request, calls Autofac's Registerinstance

'multipart/form-data' is not supported for this resource

别来无恙 提交于 2020-01-23 03:13:12
问题 I have WEbAPI2 back end. I try to send form data from postman But get this error "No MediaTypeFormatter is available to read an object of type 'StartWorkingDay' from content with media type 'multipart/form-data'.", Here is code of my controller // POST: api/StartWorkingDays [ResponseType(typeof(StartWorkingDay))] public IHttpActionResult PostStartWorkingDay(StartWorkingDay startWorkingDay) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.StartWorkingDays.Add(startWorkingDay);

NLog Exception when parsing nlog.config - Target cannot be found: 'EventLog'

﹥>﹥吖頭↗ 提交于 2020-01-23 02:49:12
问题 I'm developing a C# .NET Core 2.2 Web-Api on Visual Studio 2017 . I implement NLog 4.6.1 like described on github. When I start my application using IIS NLog does not write into the Elasticsearch . A error occurs at the line at program.cs var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger(); I find a error message at NLogError.log : 2019-06-12 09:00:49.1606 Error Penter code herearsing configuration from NLog.config failed. Exception: NLog