Tagged Questions
ASP.NET Web API is a framework for building HTTP services for clients like browsers and mobile devices. It is based on the Microsoft .NET Framework and ideal choice for building RESTful services.
0
votes
0answers
8 views
Web API 2 rest call first few calls are very slow if hasn't been called in a few minutes
This is very odd and have never heard of it. I have two rest web api 2 services running in IIS. Web Service A calls Web Service B and returns the contents of B (A acts as a facade).
If the web ...
0
votes
1answer
6 views
Attribute-based routing and handling of omitted querystring parameters
Assuming these models:
public class PagingModel
{
public int Skip { get; set; }
public int Take { get; set; }
}
public class FilterModel
{
public string Filter { get; set; }
}
Assume ...
0
votes
0answers
4 views
.Net MVC / Web API Attribute Routing triggers Download
Having added WebApi to an MVC 5 project (.aspx AND Razor engines) I am trying to add Attribute Routing however whenever I add this line:
// Web API routes
config.MapHttpAttributeRoutes();
to the ...
0
votes
1answer
13 views
Web API AuthorizeAttribute does not return custom response
How can I make IsAuthorized return my custom object while function returns false?
In my WebAPI project I have a class like;
public class CustomAuthorizeAttribute : AuthorizeAttribute
{
...
0
votes
1answer
15 views
Differentiate between MVC and WebAPI in ASP.NET 5 / MVC 6
MVC and WebAPI are being combined for ASP.NET 5 / MVC 6, however I still want to be able to differentiate between the two.
Previously, different behaviours could be implemented in the form of global ...
0
votes
1answer
10 views
IIS Express Debugging No Longer Working
I'm using IIS Express with Visual Studio 2013 on Windows 8.1 x64 for a WebAPI 2 application (all en-US here). This worked just fine roughly a month ago, but now I'm getting errors when attempting to ...
5
votes
2answers
47 views
Web Api 2 or Generic Handler to serve images?
I want to create an image handler, but i am torn between using Web API 2 or just a normal Generic Handler (ashx)
I have implemented both in the past, but which one is the most correct one.
I found an ...
0
votes
1answer
13 views
web.api cannot test action
I have created a Web.API, MVC application but ran into some trouble when trying to test it. I get this error:
"{"Message":"No HTTP resource was found that matches the request URI ...
1
vote
1answer
30 views
Calling a Web api from another Web api (web api)
Is it somehow possible to make a Web api that calls another web api?
I am using the code below to access a web api from my web api, but it never return from the call. If I use the code from a console ...
0
votes
0answers
8 views
Image folder access as URL in WebApi issue ..!
I have Image folder in hosted WEB API, while accessing image with URL "http://localhost:49245/images/abc.png" is working fine at local end, but not on hosted site at server. Showing "500 - Internal ...
-2
votes
0answers
11 views
Can we Implement OTP in MVC4 Web Api Application
As a new requirement in our project we needed to implement OTP(One Time Password) feature in the application, Can we Implement OTP in MVC4 web api? How can we do This? Please provide me links or idea
...
0
votes
1answer
19 views
Security exception in web api
I am trying to create an odata endpoint for a table valued function in sql database. I think my code is fine but some settings issue is causing me get the error :
Server Error in '/' Application.
...
0
votes
1answer
29 views
Get response in JSON from API
I am using HttpClient to consume an external API from an ASP.NET Web API controller. I am not using authentication, just a token, so I have:
using (var httpClient = new HttpClient()) {
...
1
vote
1answer
13 views
.NET web API calls are getting intercepted by angular js UI Router, returning HTML instead of calling API
I have an angularjs app, that sits on top of an MVC5 app and an WEB API backend. I am using UI Router for the Angular js routing and for now, have removed ALL $urlRouterProvider.when and ...
0
votes
1answer
29 views
Web Api 2 + EF6 - Building a DTO
For a project we are making use of EF and Web Api 2. To abstract away from our database models we are making use of DTO's. We have a factory to construct these DTO's:
public class ...
0
votes
0answers
29 views
Authorization header is null
Basic authentication Module
public class BasicAuthHttpModule : IHttpModule
{
private const string Realm = "AngularWebAPI";
public void Init(HttpApplication context)
{
// Register ...
0
votes
0answers
7 views
Handling 'model validation' with http 403, 404, 500 on Web API2
For Asp.net Web API, I came across articles that describes how to handle custom response. Some other articles described how to handle the models errors with Anotations.
But I am looking for a ...
0
votes
0answers
18 views
Excel, Word and Outlook Jquery/c# web api
So im looking to use jquery to take html from the web page to either to word, excel or outlook mail item. now originally I was going to call an api that would use Microsoft's example to return a file ...
0
votes
1answer
37 views
Asp.net MVC Web API Call Redirect to Accountcontroller Login
My code is
RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
...
0
votes
2answers
30 views
$http post via an angularjs service
I use the code below. The content of dataService is all the $http possible in my application. In the controller, I consume this function. The function call a Web Api service, this one is called and ...
0
votes
0answers
20 views
Autofac intergration with Owin/WebApi failing with parameterless constructor
I have setup an mvc5.2 webapi project and have added all of the dependencies for autofac and owin.
Within my startup class I have the following code which is taken directly from the docs Autofac Owin ...
0
votes
0answers
26 views
handling circular references when saving(post)
I am stuck with an error i can't figure out. I have a complex model with several circular references. I have tried everything i know to handle them but i am still getting a internal server error (code ...
0
votes
3answers
42 views
Null parameter on web api post method
I have a very simple web api controller:
public class CarrinhoController : ApiController
{
[HttpPost]
public string Adiciona([FromBody] string conteudo)
{
...
8
votes
1answer
46 views
WebApi Put how to tell not specified properties from specified properties set to null?
Here is the scenario. There is an web api put call to change an object in sql server database. We want only to change the fields on the database object if they were explicitly specified on webapi call ...
0
votes
1answer
19 views
Inject session objects into WebAPI controllers
I have a legacy webforms application
I've been given the task of migrating it to MCV but not throwing it all away.
I have to keep both applications running in the same project and migrate the ...
0
votes
0answers
10 views
How to generate CSV file and download from WEB API method using Media Type Formatter?
I have a requirement to export data into csv as well as pdf files from WEB API methods. To start with I wanted to get something done with csv files. I followed some references to create custom media ...
1
vote
1answer
62 views
Losing HttpContext with async await in ASP.NET Identity GetRolesAsync
This is more of an async/await question than ASP.NET Identity. I am using Asp.Net Identity, and have a custom UserStore, with a customized GetRolesAsync method. The UserManager is called from a ...
0
votes
0answers
28 views
Change the ID field AspNetUsers string table to Integer in Asp.net Identity
I created a Web project to ASP.NET MVC Web API and C # in VS2013 Update 4, change the connection string to a SQL Server 2008 R2 and after having created the database with "Asp.Net Identity" add ...
2
votes
2answers
44 views
Passing complex array from Controller to View ASP.NET MVC
I have a model in my ASP.NET MVC application:
public class SearchArrayModel
{
public long ID { get; set; }
public string Name { get; set; }
public struct AttribStruct
{
public ...
0
votes
0answers
21 views
WebApi duplicate actions
I'm using ASP.net help pages to generate documentation for my WebApi. The problem is that the ASP.net help pages is duplicating the controller action for each area. The folder structure looks like the ...
0
votes
0answers
14 views
AutoMapper throwing 'Sequence contains no elements' (InvalidOperationException)
I'm trying to project a list of entities directly from an IQueryable using AutoMapper to a dto, however it always seems to fail with an InvalidOperationException stating that The sequence contains no ...
0
votes
1answer
15 views
ASP.NET MVC and Web API model binding - how do I bind to properties with names disallowed by the language?
An example of basic model binding to an object in ASP.NET MVC or the ASP.NET Web API might look like this (using C# as example):
public class MyModel
{
public string value1 { get; set; }
...
0
votes
0answers
7 views
Authorize roles specific to category-branch
I have seen that the roles need to be 'locked down' at compile time. So I am wondering if this can be done.
Right now, we have controllers, that we can lock down controllers/methods based on roles ...
0
votes
0answers
6 views
Use OData $select to cherry pick fields from related object
I'm using WebAPI 2.2 with OData V4.
It is possible for me to use $filter=RelatedObj/PropertyName eq 'Some Value' to filter a list of entities based on a related object property value.
However, when ...
0
votes
1answer
18 views
Conceptually(not technically), is ASP.Net Web API a subset of SignalR?
I know that Web API is for RESTful services and SignalR is for bidirectional(duplex) communication.
But SignalR can be used as RESTful service as well.
What is the advantage of Web API over SignalR?
...
0
votes
0answers
11 views
entity framework many to many relationship composite primary key with same name
I have these tables in the db (ef database first, i can't change db structure)
Departments
-------------------------
CompanyId (pk,fk)
BuildingId (pk,fk)
DepartmentId (pk)
...
...
Floors
...
0
votes
0answers
18 views
Parameter binding with optional model?
Usually, my web api controllers look like this:
public IHttpActionResult GetDogs(int? page = null, int? pageSize = null) {
return Ok("Who let the dogs out?");
}
The route parameters for the ...
0
votes
1answer
21 views
Export data in CSV,PDF format using WEB API and angularjs
I am working on a project with Web API on the server side and angularjs on the client side. One of the requirement is to retrieve data from database based on some parameters and export it in csv as ...
1
vote
2answers
54 views
Async calls in Web Api
In asp.net Web API how can I call long running blocking actions asynchronously?
I have a web api controller action that needs to make a relatively (10 seconds, as an example) long running DB call. ...
0
votes
0answers
22 views
Web API translating input into random int
not sure whether the subject is the best description for this problem but I am getting an unusual problem where I have a single Web API operation and a single field on a request and for some odd ...
0
votes
0answers
12 views
how to resolve web api odata 406 error without deleting tempDirectory specified in web.config file?
A simple web site with only one web api v4 controller and a few classes
Wep Api controller and its Service Action is set dynamically as
ActionConfiguration objResourceConfig = ...
0
votes
1answer
20 views
Cannot read property 'client' of undefined using SignalR
I've been working all day on this with no luck.
I have also tried (almost) every single SO question, but I didn't get it to work...
I'm running web api with very simple SignalR push message and ...
0
votes
0answers
26 views
error while post data using webapi
i have created webapi, i am facing some problem when i am posting the data using this api, i am very much fed up can anyone help me this.
<script ...
1
vote
1answer
22 views
What's the best way to map objects into ember model from REST Web API?
The topic of this post is: my solution is too slow for a large query return.
I have a Web Api serving REST results like below from a call to localhost:9090/api/invetories?id=1:
[
{
...
0
votes
1answer
13 views
How can I handle exceptions in Web API 1.0 at my BaseAPIController
I am currently using Web API 1.0 and .NET 4.0
I need a function that can take care of the noise of catching and handling exceptions in my Base API so that I dont need to write that in every RESTful ...
0
votes
0answers
24 views
Hangfire deployment considerations [on hold]
I have three web applications,
2 ASP.NET MVC 5 Web applications
1 ASP.NET Web API project
I am in the way to integrate Hangfire in this infrastructure to handle all background executions needs ...
0
votes
0answers
16 views
Web API Custom identity using Usermanager
I want to implement custom authentication on Web API. I already did this using this post (link here).
The problem is that, now, I have to use two tables in the database as tables for users. So now, ...
0
votes
0answers
16 views
Web API w/CORS Generating No HTTP resource was found that matches the request URI and a 404 message when navigating to API/
Hello and a thank you to anyone taking the time to read this issue and a gigantic thank you to those that respond with a possible fix. Currently I have modified this tutorial ...
0
votes
1answer
9 views
Error calling webapi from sharepoint
I've got a sharepoint webpart that makes a jquery ajax call to a webapi, but when inspecting the call with fiddler i get a error message that says "Session #84: The remote server (srvkbhnws001) ...
2
votes
2answers
63 views
Repository Pattern or not? ORM needed? MVC Web api REST [on hold]
I am pretty new to building restful web api's but I have been doing a lot of studying and have a strong understanding of the basics. I have built a service for my company using the latest best ...