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
4 views
Web API Routing changes after DB Refresh
This is an exceedingly strange problem and I'm only including it as an oddity in case someone's seen it before.
I am on C#, ASP.Net web api, Fluent Nhibernate and SQL Server 2012
I have a Meal ...
0
votes
0answers
7 views
How do I pass multiple string parameters into WebAPI
I'm trying to write a simple WebAPI controller to validate a userId and password. Both parameters are strings and it's a bit frustrating that this always seems to be so difficult.
The Controller code ...
0
votes
0answers
9 views
How to make a right DTO class for request XML body on consuming Web API service
I am using RestSharp with C# codes to PUT data object (my_object) for a WEB API service operation that supports only XML format.
My question:
How can I make a right DTO class (e.g. Analytics, please ...
-4
votes
0answers
13 views
Can you give example of detecting changes in Entity Framework 6? [on hold]
I am trying to override DbContext.SaveChanges(). I want to be able to build a list changes to an entity's properties on one type of entity, called "Ticket", and have those changes serialized to be ...
1
vote
1answer
41 views
How can I POST form data to ASP.NET WebAPI 2?
I'm having trouble accessing parameters submitted via POST in my ASP.NET WebAPI 2 application. I hav a very trivial controller and an action, which simply captures the parameter and returns 200.
...
0
votes
0answers
13 views
Return CreateErrorResponse or throw new HttpResponseException
I am new to Web API's (using C# in VS 2012) and attempting to help on a project that involves returning more meaningful errors to an AngularJS front-end, but I am not sure if there is a preferred ...
0
votes
0answers
20 views
Why can I no longer bind to the HttpContext using an ActionFilterAttribute?
I am using ASP.NET MVC 4 Web API alongside AutoFac and Fluent NHibernate. In the past, I've had no problem getting the following code to work:
public override void ...
2
votes
0answers
13 views
Should OWIN self host app using Ninject OWINHost need system.web?
I'm trying to create a Windows service with OWIN self hosted WebAPI with Ninject . I got it to work but I had to add a reference to system.web, which seems wrong. Without a reference to system.web I ...
0
votes
0answers
11 views
Web API not working when deployed on IIS
I'm writing an application using .NET Web API. The app works fine with IIS express, I can invoke services from a c# application and from an Android one. When I publish it on IIS it doesn't work. Is ...
0
votes
0answers
19 views
What is going on when the action return `Stream`?
For example, we have simple code:
[HttpGet]
public HttpResponseMessage Get()
{
var path = "path_to_file"
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
...
1
vote
1answer
19 views
Make WebAPI internal to Azure
I need to make a web api internal to Azure cloud. What attributes or setting to make?
setup
I have two application deployed in azure cloud.
1st is a frontend MVC5 application with UI.
The 2nd is a ...
0
votes
2answers
30 views
How to send array with other parameters to a web api using angularjs
I am sending an array of integers to the web api controller method successfully using angularjs $resource custom method without params defined. When I add other parameters with an array type parameter ...
0
votes
1answer
18 views
Authorize user on the basis of username in webapi
I want to apply permission on some method using [Authorize] in Web Api, on the basis of the logged in username.
[Authorize(Users = "Alice")]
public ServiceResult<List<DefaultCities>> ...
0
votes
1answer
5 views
Fiddler: The connection to 'localhost' failed. with owin selfhost
I have the following simple console app hosting a webapi using Owin SelfHost. The response from the console itself works but if trying from fiddler i just get a connection to localhost failed. (same ...
1
vote
0answers
19 views
Simple Injector Web Api Controller Constructor Injection Failing
My Web Api app is failing when trying to instantiate an injected controller. I'm using Simple Injector. Bootstrapping the injector is as follows:
[assembly: ...
1
vote
1answer
22 views
Retrieving Action Signature Custom Attributes
Suppose I have an action method that looks like this:
[return: Safe]
public IEnumerable<string> Get([Safe] SomeData data)
{
return new string[] { "value1", "value2" };
}
...
0
votes
1answer
14 views
Property not found in web api
The Result property in actionExecutedContext.Result cannot be resolved. Any ideas why?
Here's my code.
using System.Collections.Generic;
using System.Linq;
using System.Net;
using ...
0
votes
1answer
34 views
JSON not binding correctly in WebApi action
I'm creating and api using asp.net webapi
For some reasons this json:
JSON => {"page":"1","count":"10","sorting[name]":"asc"}
JSONString = ...
1
vote
0answers
13 views
c# Web Api with CORS Enabled and the dreaded No 'Access-Control-Allow-Origin' header is present on the requested resource
I have a C# Web API project. I created a Controller using the Web API 2 standard. I am trying to enable CORS on only one action, this is what I have:
namespace MyProject.Controllers
{
public ...
0
votes
1answer
10 views
Execute a simple call to a WebAPI Get using RestRequest and a single string parameter
I have the following code in my receiving controller:
[Route("api/StudentUserId/{string}"), HttpGet]
public StudentDto StudentUserId(string userId)
{
StudentModel sm = new ...
0
votes
0answers
12 views
in asp.net web api, is it possible to put the image data together with other fields in the get result
Suppose the model is like
driver
{
lastname,
firstname,
byte[] picture
}
is it possible to return this model in the Get or Post method? I guess it's not because of the content type, but just want ...
1
vote
1answer
43 views
How do I extend IdentityRole using Web API 2 + AspNet Identity 2
I am attempting to extend the AspNet IdentityRole class provided in the Web API 2 (With Individual Accounts) template in the latest version of Visual Studio 2013. When I hit /api/roles it returns an ...
0
votes
1answer
14 views
Reading & Storing JSON data into knockoutja observableArray
I have following Json returned from an web api
{"PayHistories":
[{"Id":3,"RateChangeDate":"2014-09-03T06:00:00","Rate":10.00,"PayFrequency":7,"JobTitle":"Production Manager","Gendre":"M"}],
...
1
vote
0answers
10 views
Social Network API design for Like, Comment, and other Interactions?
Suppose I have a website where I showcase people's artwork, recipes, and journals (and this list is likely to grow). I want people to be able to comment, like, flag, etc. all of them.
I'm not looking ...
0
votes
0answers
13 views
How to mock dependencies for a WebApi 2 controller when using MEF 2 (System.Composition)?
With MEF (System.ComponentModel.Composition) it's possible to add mock objects to the container.
container.ComposeExportedValue(mock.Object);
ref: How to use Moq to satisfy a MEF import dependency ...
0
votes
2answers
30 views
Using WebSockets with ASP.NET Web API
What is the preferred method for using raw websockets in an ASP.NET Web API application?
We'd like to use binary WebSockets on a couple of our interfaces of our ASP.NET Web API application. I'm ...
3
votes
0answers
24 views
Generate JSON Schema for ASP.Net Web API
I'm looking to generate JSON Schema for a WebAPI, including documentation from the XML comments.
Its primarily so that I can then import that into our API docs (using apiary.io)
I've managed to get a ...
0
votes
0answers
13 views
Additional information: Google.Apis.Requests.RequestError User cannot access account
An unhandled exception of type Google.GoogleApiException occurred in Google.Apis.dll Additional information: Google.Apis.Requests.RequestError User cannot access account
string path ...
0
votes
1answer
20 views
Send complex DTO to web api using jquery ajax
I have a DTO Object like that:
public class ImageDto : EntityDTO
{
public ImageDto()
{
Position = new PositionDTO();
Rotation = new RotationDTO();
Size = new ...
0
votes
0answers
25 views
AngularJS/MVC/WebApi Cookie and Token Auth
This is somewhat related to this question I asked. A new app I am starting will have the following structure - a very small ASP.NET MVC component which is a wrapper for the heart of the app which is ...
1
vote
1answer
15 views
Hardcoded Web API calls in code versus multiple environments
Actually, I hardcode my Web API calls like this :
$http.get('my/production/web/api/method');
If I want to switch to a test environment, which is another Web API, I don't want to manually change ...
1
vote
0answers
16 views
Use External Access Token or Local Access Token
I am developing an application using ASP.NET MVC 5.2.2, Web API 2.2 and Katana/OWIN 3.0. The application uses ASP.NET Identity 2.1 for local accounts and database.
I am using OAuth Authorization ...
1
vote
2answers
23 views
Disadvantages to Web Api methods returning Tasks
Why is the practice of returning a Task<T> from Web Api methods not the default and in the methods that you get when you create a new Web Api Controller in Visual Studio?
Are there any ...
0
votes
1answer
52 views
At the same controller, GET and POST works, but PUT don't
I'm developing a Web Api 2 service with latest .NET Framework and C#.
I have a controller with these methods:
public IEnumerable<User> Get()
{
// ...
}
public User Get(int id)
{
// ...
0
votes
0answers
23 views
Retrieving additional profile information from Facebook during external login/register with ASP.NET Web API 2.0 and Identity
There appears to be a lot of documentation on how to get additional information from a Facebook profile using ASP.NET Identity and an MVC client, but I can't seem to find anything on how to access the ...
1
vote
0answers
28 views
How to configure number of TCP connections using dotnet (nugget package) httpclient?
I used to use HttpWebRequest.ServicePoint.ConnectionLimit (http://msdn.microsoft.com/en-us/library/system.net.servicepoint.connectionlimit(v=vs.110).aspx) to configure number of TCP connections opened ...
0
votes
0answers
11 views
ASP.NET Web API Security Token Generation Mechanism
I am using ASP.NET Web API to generate publicly accessible services that can be used by authenticated users. I am using token based authentication (OAuth Bearer tokens). ASP.NET has everything ...
0
votes
2answers
32 views
NHibernate SaveOrUpdate Repository does not Update but Save Data
I have two Controllers that call the same CommandHandler for SaveOrUpdate. One of the Controller is the normal MVC Controller while the other one is a WebAPI ApiController. Both works fine in Save ...
0
votes
0answers
8 views
Angular-tree-ui JSON Data with $http
I'm currently been using the angular-tree-ui component, which is a nice little component that allows nesting of hierarchical data with drag and drop support.
All has been going well until I started ...
2
votes
2answers
59 views
How to pass bitArray from javascript to c#
I want to pass bitArray from my javascript file to my method in webApi
I create bitArray as below in my javascript file
var myBits = new BitArray(2);
myBits.setAt(1,false);
myBits.setAt(2,true);
...
0
votes
1answer
42 views
Uploaded 'multipart/form-data' to ASP.NET Web API action, not readable in bufferless mode
I'm building an ASP.NET Web API endpoint that accepts 'multipart/form-data' requests. I implemented it as described in this article using .NET Framework 4.5 and Web API 2.1. A simplified version of ...
0
votes
2answers
19 views
Web Api Rest method receives JObject wrapped in another JObject as a key value
I have problem with json which is sent from the sencha touch client to the rest web abi web service.
When i send POST request from Sencha it looks like:
var paramsData = Ext.encode({
...
0
votes
1answer
23 views
ASP.NET Web API read model inside action filter
I have a special case when I need to get some data from request body (or model let say) inside action filter (AuthorizationFilterAttribute). I have found this way:
public async override Task ...
0
votes
0answers
22 views
ASP MVC 5 WebAPI vs Ajax.ActionLink
I am having some difficulties understanding the difference between ASP.Net MVC WebAPI Controllers (System.Web.Http.ApiController) and @Ajax.ActionLink (PartialViews).
As my knowledge of MVC 5 and ...
1
vote
0answers
26 views
curl sending null data on POST request to web api
I want to POST data through curl windows 64 bits onto a asp.net web api(using C#) .
However every tim i do so, the control passes to the HttpPost method however the values of the accepting parameter ...
-4
votes
0answers
18 views
I need code in which describe how google content api for shopping works in c#.net in version2 [on hold]
I need code in which describe how google content api for shopping works in c#.net (version2).
thanks in advance
0
votes
0answers
14 views
Sync API in .net
I have a relational DB with a few tables around 9-10 tables, i have to create a API to return all the Data from these tables to be synched into a device SQLLite db.
Is it a good approach to go with ...
0
votes
1answer
9 views
web api tracing, library versions
My original problem was that I didn't get any xml response - only json - after changed to use XmlSerializer:
var xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
xml.UseXmlSerializer ...
-2
votes
1answer
32 views
How to communicate with an web application to other web applications? [on hold]
I need information about how to communicate with an web application to other web applications using Asp.net MVC , Now i am working with job posting site(asp.net MVC application) . My exact criteria is ...
0
votes
0answers
18 views
WebApi 2.2 + Chrome = CORS 405 error
I have 2 projects setup:
A Website that just uses HTML and durandal and calls a webapi post method using $.ajax. It's on localhost:33432 and calls the second site (note that the ajax call doesn't ...