asp.net-web-api2

Issue when using IAppBuilder.UseWebApi

最后都变了- 提交于 2019-12-24 08:32:51
问题 I am creating a SPA (Singe Page Application) using WebApis in ASP .NET MVC5. For WebAPis I am using attribute routing. For requests other than Web API, I have configured a Catch-All route that maps to Home controller and Index action Here is my code I have the following configuration code in my StartUp.cs file using System.Web.Routing; [assembly: OwinStartup(typeof(MyApp.Startup))] namespace MyApp { public class Startup { public void Configuration(IAppBuilder app) { GlobalConfiguration

jquery.download fails to make API call which is [Authorize] restricted

六眼飞鱼酱① 提交于 2019-12-24 07:56:33
问题 I am trying to download a file using jquery.download plugin, for this I make an API call, but the issue is my API is under [Authorize] restriction, hence API call is not being made. I think it is missing Authentication header. My function is function ExportStS(getAll, type, print) { var path = api_url + 'api/SharedDocument/GetStateSummaryExport'; $.fileDownload(path, { httpMethod: "POST" }); return false; } When I see the console I see this message Failed to load resource: the server

Why there are different request headers for same ajax call?

▼魔方 西西 提交于 2019-12-24 07:25:50
问题 How could request headers be different for the same call and for the same JS code from the same browser? I have one web API project and I am calling a method in this API from two different projects (CORS calls), using $http.get method of AngularJs 1.X . $http.get("http://local.api:9002/api/default/get") .then(function success(response, status, headers, config) { console.info(response); }, function error(response, status, headers, config) { console.info(response); } ); This is the same code

Swagger UI nested expandable groupings

瘦欲@ 提交于 2019-12-24 06:34:48
问题 I am using SwaggerUI for documenting API endpoints. Currently they are grouped by controller name, in one long list. You can then expand each controller to view the operations. Everything standard. What I would like to do, is group the controllers under common expandable groups. So for example, you have a Pet group, which can be expanded, to reveal Cat and Dog controllers, which can then in turn be expanded to show their respective operations. I have tried using Tags to accomplish this, but

ASP.Net Web API Swashbuckle how to ignore HttpRequestMessage

▼魔方 西西 提交于 2019-12-24 04:06:08
问题 I'm using Swashbuckle to generate docs for an API. My controller methods looks like this: [ResponseType(typeof(CategoryCollectionModel))] public HttpResponseMessage Get(HttpRequestMessage request, [FromUri]Paging paging) { var input = new CategoriesListQuery.Input { Page = paging.Page, Size = paging.Size }; var result = this.queryInvoker.Execute<CategoriesListQuery.Input, CategoriesListQuery.Result>(input); var items = Mapper.Map<CategoryCollectionModel>(result); return request.CreateResponse

ASP.Net Web API Swashbuckle how to ignore HttpRequestMessage

喜你入骨 提交于 2019-12-24 04:06:04
问题 I'm using Swashbuckle to generate docs for an API. My controller methods looks like this: [ResponseType(typeof(CategoryCollectionModel))] public HttpResponseMessage Get(HttpRequestMessage request, [FromUri]Paging paging) { var input = new CategoriesListQuery.Input { Page = paging.Page, Size = paging.Size }; var result = this.queryInvoker.Execute<CategoriesListQuery.Input, CategoriesListQuery.Result>(input); var items = Mapper.Map<CategoryCollectionModel>(result); return request.CreateResponse

An error has occurred.“, ExceptionMessage: ”Invalid 'HttpContent' instance provided

喜夏-厌秋 提交于 2019-12-24 03:53:16
问题 Trying to add a file to an http rest call I get this error: responseJson = {Message: "An error has occurred.", ExceptionMessage: "Invalid 'HttpContent' instance provided. It does n…rting with 'multipart/'. ↵Parameter name: content", ExceptionType: "System.ArgumentException", StackTrace: " at System.Net.Http.Formatting.Parsers.MimeMulti…tpControllerDispatcher.d__1.MoveNext()"} my react component: import React, { Component } from 'react'; import { Row, Col } from 'antd'; import PageHeader from

An error has occurred.“, ExceptionMessage: ”Invalid 'HttpContent' instance provided

空扰寡人 提交于 2019-12-24 03:53:10
问题 Trying to add a file to an http rest call I get this error: responseJson = {Message: "An error has occurred.", ExceptionMessage: "Invalid 'HttpContent' instance provided. It does n…rting with 'multipart/'. ↵Parameter name: content", ExceptionType: "System.ArgumentException", StackTrace: " at System.Net.Http.Formatting.Parsers.MimeMulti…tpControllerDispatcher.d__1.MoveNext()"} my react component: import React, { Component } from 'react'; import { Row, Col } from 'antd'; import PageHeader from

WebAPI caching for http Post

浪尽此生 提交于 2019-12-24 03:46:12
问题 As a part of our refactoring and move to WebApi 2, we are thinking of caching our responses. Based on my research OOB only the Get & Head are supported, however all our controllers only expose POST methods, are there are custom libraries or articles that can help us with implementing caching for POST actions ? 来源: https://stackoverflow.com/questions/30596582/webapi-caching-for-http-post

ERR_SPDY_PROTOCOL_ERROR when returning file from ASP.NET action

Deadly 提交于 2019-12-24 02:29:07
问题 I have some old Web API action method which returns CSV file. It worked for long time, but recently stopped. Now it causes ERR_SPDY_PROTOCOL_ERROR. ERR_SPDY_PROTOCOL_ERROR in Chrome is often associated with Avast security as described here. In my case however it's not caused by Avast, and other web browsers throw exceptions too. My action method looks as follows: [HttpGet] [Route("csv")] public HttpResponseMessage SomeMethod([FromUri]SomeSearchCriteria sc) { using (MemoryStream stream = new