asp.net-web-api2

Large File download from SQL via WebApi after custom MultipartFormDataStreamProvider upload

拟墨画扇 提交于 2019-12-08 00:40:39
问题 This is a follow up to a question I had asked previously that was closed for being too broad.Previous Question In that question I explained that I needed upload a large file (1-3GB) to the database by storing chunks as individual rows. I did this by overriding the MultipartFormDataStreamProvider.GetStream method. That method returned a custom stream that wrote the buffered chunks to the database. The problem is that the overriden GetStream method is writing the entire request to the database

How can I configure a route for WebApiConfig to redirect some requests to static html page?

此生再无相见时 提交于 2019-12-08 00:10:48
问题 I'm working on a webApi application, and the api I want to get is the following: api/v1/lists/?params... api/v1/meta/?params... api/v1/debug There are ApiControllers that work fine for "lists" and "meta" routes, but api/v1/debug should return a static html page. I could think of two ways of implementing it: via special controller that would return something like View("mypage.html") or configure routes in WebApiConfig to redirect requests like api/v1/debug to mypage.html However, I couldn't

PushStreamContent stream does not flush under load

跟風遠走 提交于 2019-12-07 22:56:58
问题 I am using PushStreamContent to keep a persistent connection to each client. Pushing short heartbeat messages to each client stream every 20 seconds works great with 100 clients, but at about 200 clients, the client first starts receiving it a few seconds delayed, then it doesn't show up at all. My controller code is // Based loosely on https://aspnetwebstack.codeplex.com/discussions/359056 // and http://blogs.msdn.com/b/henrikn/archive/2012/04/23/using-cookies-with-asp-net-web-api.aspx

Multiple types were found that match the controller

不问归期 提交于 2019-12-07 21:24:36
问题 I'm trying to api versioning using header but in different folder structure like below. In Controller folder have V1 sub folder inside that CustomerController.cs and In Controller folder have V2 sub folder inside that CustomerController.cs when I user api version using URL above works fine. my issue is When I try this approach with header it is giving me below error: { "Message": "An error has occurred.", "ExceptionMessage": "Multiple types were found that match the controller named 'customer

modelbinder IsMultiPartContent always returning false. How to upload file with react

让人想犯罪 __ 提交于 2019-12-07 20:47:25
I have the following react component import React, { Component } from 'react'; import { Row, Col } from 'antd'; import PageHeader from '../../components/utility/pageHeader'; import Box from '../../components/utility/box'; import LayoutWrapper from '../../components/utility/layoutWrapper.js'; import ContentHolder from '../../components/utility/contentHolder'; import basicStyle from '../../settings/basicStyle'; import IntlMessages from '../../components/utility/intlMessages'; import { adalApiFetch } from '../../adalConfig'; export default class extends Component { constructor(props) { super

Webapi 2.0 how to implement refresh JWT token when access token expired

穿精又带淫゛_ 提交于 2019-12-07 20:32:09
问题 I am quite new in web API implementation, I have created a web API service to use it with ASP.net web form applications as well as some stand alone applications(C# Console/Windows application) using HttpClient object. I have implemented a basic JWT access token authentication with expiration time limit in web api, this authentication technique is working fine until token not expired, when token get expired web api does not accept request as token has expired! which is fine as per

Uploading image in ASP.NET Boilerplate

血红的双手。 提交于 2019-12-07 18:46:04
问题 When posting an image, HttpContext.Current.Request is null . Is there any simple way to achieve this? I am using dropzone.js on client side. Project is Angular with Web API (ASP.NET Core 2.0) template. [HttpPost] public HttpResponseMessage UploadJsonFile() { HttpResponseMessage response = new HttpResponseMessage(); var httpRequest = HttpContext.Current.Request; if (httpRequest.Files.Count > 0) { foreach (string file in httpRequest.Files) { var postedFile = httpRequest.Files[file]; var

ASP.NET WebAPI 2 deserializing JSON sets some nested objects to null

主宰稳场 提交于 2019-12-07 17:44:15
问题 I am encountering an issue while sending some JSON from an AngularJS application to a ASP.Net WebAPI 2 back-end. What happens is that some properties from the incoming request are set to null during deserialization. Part of the request where the deserialization bug occurs: 12: {row: 9, column: 1, order: 13,…} column: 1 domainEntityProperty: {$id: "157", id: 2616,…} order: 13 renderType: {$id: "39", id: 1, class: "input"} row: 9 Above snippet is piece of the request that is being sent. It's a

Elmah.axd on WebAPI 2.2 - No HTTP Resource was found

杀马特。学长 韩版系。学妹 提交于 2019-12-07 15:42:44
问题 I'm trying to access /elmah.axd in my broswer, but it returns: {"message":"No HTTP resource was found that matches the request URI 'http://services.domain.com/elmah.axd'."} The server is local (127.0.0.1) and even on that I have my web.config Elmah settings to secure it this way: <elmah> <security allowRemoteAccess="true" /> </elmah> My WebApiConfig looks like: public static void Register(HttpConfiguration config) { // Web API configuration and services // Locally only you will be able to see

Required attribute on action parameter doesn't work

寵の児 提交于 2019-12-07 15:06:38
问题 The code is like: [HttpPost] public ResultEntityVM Register([FromBody,Required] RegisterParam createAssessorParam) { if (ModelState.IsValid == false) { return null; } //other code ResultEntityVM vm = new ResultEntityVM(); return vm; } When the parameter createAssessorParam is null , the value of ModelState.IsValid is true . Why? If I want to auto judge the parameter is null or not, what can I do? Don't I can only write the code: if(RegisterParam != null) { //other } 回答1: I've run into the