Questions tagged [webapi2]

127 questions
2
votes
2 answers

using global exception handeling messes up DelegatingHandler

When ovveride the IExceptionHandler, the response does not reach the DelegatingHandler when a unexpected exception occurs. How can I fix this? In webapi 2, I want to implement a audit logger for request and response messages. I also want to add a…
lordkain
  • 3,061
  • 1
  • 13
  • 18
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
  • 3
  • 15
2
votes
1 answer

Asp.net WebApi2 - Avoid scraping, avoid direct acces via browser, only allow ajax calls from domain

Im new to webapi2, I`v implemented a simple WebApi2 project, which unlocks some data from a third party webservice (which is called with credentials) This works fine, but now Im looking for ways to avoid scrape content from our webapi. It isn`t…
Dossie
  • 57
  • 6
2
votes
1 answer

I want to Create and Image handler that will resize the Image and return Images to my application

This is the same question asked before and the answer is also verified but in My Project I am using WebApi 2 and want return image from Ihttpactionresult I have searched and lot and done some code Which I don't know if I am doing right.. I also…
Sa Nuj
  • 103
  • 10
2
votes
1 answer

how to read file data in web api 2?

I use the MultipartFormDataStreamProvider to read uploaded files as the snippet below illustrates. However this isn't secure as it saves the files straight to temp. First, I want to inspect the raw bytes and perform some validation checks. Please…
Fred Johnson
  • 2,539
  • 3
  • 26
  • 52
2
votes
1 answer

GetAsync : not returning HttpResponseMessage

The apps should receive httpresponsemessage from LoginUser() but it becomes not responding. private void button1_Click(object sender, EventArgs e) { if (LoginUser(tUser.Text, Password.Text).Result.IsSuccessStatusCode) { …
1
vote
0 answers

Web API Allow Anonymous Not Working With Web API 2

I have two problems with the following method (Web API 2, C#, .Net Framework 4.8): [AllowAnonymous] public JSONObject TestMeAno() { return new JSONObject() { id = 333 }; } I have implemented a custom authorization filter…
Hasan Shouman
  • 2,162
  • 1
  • 20
  • 26
1
vote
0 answers

Recieve Bytearray in API Method

hi I am trying to implement webhook receiver on our end in WebApi2.as per webhook sender docs they will send encrypted stream ( check doc below for more clarification ). The encrypted payload is stored in the body of the message as a stream of…
Muhammad Faisal
  • 155
  • 2
  • 13
1
vote
1 answer

WebApi2: routing vs. query string

I was under the impression that REST was supposed to use routing, like this: http://server/api/accounts/2 Rather than something like this: http://server/api/accounts?id=2 I've seen lots of examples using the query string, but I would've expected…
birdus
  • 7,062
  • 17
  • 59
  • 89
1
vote
1 answer

Formarray doesnt show all the records received from service/api

I am trying to patch the object received from webapi to an angular reactive form. The form also has a formarray. But, despite having more than 3 or more records only 2 records are being patched to the formarray of the reactive form. I have two…
1
vote
1 answer

Call to httpclient throws a 404 response when using OWIN SelfHost

I have the following call to a selfhosted OWIN API: const string baseAddress = "http://localhost:9000/"; using (WebApp.Start(url: baseAddress)) { var client = new HttpClient(); var response = client.GetAsync(baseAddress +…
Spikee
  • 3,967
  • 7
  • 35
  • 68
1
vote
2 answers

Hide an api endpoint in release build

I am working on a Asp.net web api project. I recently created an end point for documentation using config.Services.GetApiExplorer(); What is the best way to hide this endpoint in production and still make it available for all other developers in my…
Anurag
  • 307
  • 5
  • 9
1
vote
1 answer

How to secure a web api from user end

System will generate a URL and send to customer mobile / email. When the user click the URL link, it should call the web api service to get some data and display. But my web api service will not allow any requests without credentials in the…
King_Fisher
  • 1,171
  • 8
  • 21
  • 51
1
vote
3 answers

Redirect https www to https non-www in web api 2 azure website

In a Azure portal app, I configured traffic to redirect to https but https://www won't redirect to https:// Redirection from http://, http://www both work correctly. Those are rules I have in web.config in azure app.
Dazhush
  • 1,575
  • 1
  • 12
  • 18
1
vote
2 answers

Regex validation for memo field (client and server side) with few special tags

Have been going over this problem for two days without any real luck. I am using asp.net webapi2 with jquery ajax on client side. I have an edit box for entering memo text, allowable characters are ^[©a-zA-Z0-9\u0900-\u097f,\.\s\-\'\"!?\(\)\[\]]+$…
1
2
3
8 9