Questions tagged [webapi2]
126 questions
7
votes
2 answers
How do you specify the location when using handleexeption annotation for a 302 status code
Using c# Web Api 2, I have code that throws an InvalidOperationException. When returning a status code of 302, how do provide a location for the redirect using the HandleException annotation?
[HandleException(typeof(InvalidOperationException),…
TheEmirOfGroofunkistan
- 5,218
- 6
- 33
- 51
4
votes
1 answer
ASP.NET Web API 2 primitive type from body (boolean) error
I have an action
[HttpPatch]
public IHttpActionResult foo(int id, [FromBody]bool boolVariable)
{
return Ok();
}
I am still debugging and when I try to send some data with Postman I get a strange error
"Message": "The request is invalid.",
…
john
- 41
- 1
- 3
4
votes
1 answer
ASP.NET Web API 2 on Visual Studio for Mac 2017 RC
I am new to Mac and was trying to build a Web API2 with Visual Studio 2017 for Mac. I am not able to see Web API 2 packages (Controller option is missing, I am able to create a MVC project but even when I select Empty Web Application -> Web API…
DeiJ Wrapp
- 106
- 1
- 11
3
votes
1 answer
Is it possible to pass more than one complex type parameter separately in the web API 2 Controller post method?
I know [FromBody] allows only one complex type as a parameter. I just wanted to know, is there any other way to do so? Any help or knowledge would be greatly appreciated! Thanks! :)
This is my controller
public HttpResponseMessage Post([FromBody]…
Ravikant Gupta
- 221
- 1
- 9
3
votes
2 answers
TotalCount for paging with dapper
I'm using dapper to get result set from stored procedure into object list and return it to the client as json:
public IHttpActionResult Test()
{
List gridLines;
var cs =…
Simon
- 1,753
- 4
- 25
- 45
2
votes
0 answers
Using [FromBody] in GET Method of WebApi Controller
So I know how to use [FromUri] and [FromBody] on a "Post" method of my WebApi Controller. Needless to say [FromUri] on a "Get" method is unnecessary but explicit, and works well. My problem is I want to WebApi to parse my HttpBody on a "Get" method…
griftopia
- 75
- 2
- 10
2
votes
2 answers
Calling angular 4 router with Multiple parameters from C#
I want to call router with multiple parameters using C#.Here is i am making url
var _email = UtilityConverter.Encrypt(Email);
var _userId = UtilityConverter.Encrypt(Convert.ToString(UserId));
//…
Shamshad Jamal
- 249
- 3
- 15
2
votes
1 answer
C# MailMessage with attachment breaks subject encoding
I'm sending e-mails with System.Net.Mail.SmtpClient. The problem is that when I add an attachment to the MailMessage the received e-mails subject and the attached filenames decoding goes wrong.
When the subject or attachment name string contains…
darph
- 29
- 4
2
votes
1 answer
method not found: System.Web.Http.Results.UnauthorizedResult
I'm writing some authentication logic in my Web API 2 app and I'm getting the error in the subject line. At first I was just returning Unauthorized() but then I got the error in the subject line. When I revisited the code I noticed that…
user9393635
- 1,187
- 1
- 8
- 24
2
votes
1 answer
Testing filters with IDependencyScope in Web API
I have WebApi simple NUnit Test
[Test]
public async Task Test()
{
var attribute = new TestAuthenticationAttribute {ApiVersions = new[] {"v1"}};
System.Web.Http.Controllers.HttpActionContext context = CreateExecutingContext();
var…
Oleg Makarenko
- 89
- 4
2
votes
1 answer
Azure appSettings / connectionStrings not transforming my web.config
I've followed what seemed to be a very straight forward setup to configure azure to transform my web.config but it isn't working as I expect. Here's what my web.config looks like locally.
Here's what my appSettings section looks like in the Azure…
Shane Drye
- 93
- 3
2
votes
1 answer
CORS - Delete and Put are not working,
I did all the setting,
Standerd web api config
Added all origins
AllowAnyMethod,AllowAnyHeader,SupportsCredentials,AllowAnyOrigin set to true
From IIS 7.5 delegation , set values to Read/Write
but still not able to make Delete and Put…
Amol Hegana
- 117
- 1
- 8
2
votes
3 answers
HTTP 405 Errors after Publishing Web API 2 Applications
I have a Web Api Controller and i have tested all actions on localhost and it works well.But when i Published it on Web Server,Just Actions with [HttpGet] works and [HttpPost] Actions return Http 405 error
public class ContentController :…
mohsen
- 1,390
- 1
- 13
- 37
2
votes
1 answer
User.Identity.IsAuthenticated always returns false
I'm implementing REST API using ASP.NET WEB API 2.I have default AccountController implementation with method for // GET…
Helga Lukava
- 21
- 1
- 4
2
votes
3 answers
How to pass two different types parameters in http POST method using angularjs to Web API?
First parameter is a complex type object(JSON) and second parameter is a simple type(String).Here I am using Web API 2.
I am putting my code below.
Web API
public class UserDetailsModel
{
[Key]
[EmailAddress]
public string…
Om Prakash Gupta
- 111
- 2
- 15