Questions tagged [asp.net-mvc-web-api]
The asp.net-mvc-web-api tag has no summary.
90 questions
0votes
2answers
748views
Best practice ASP.NET MVC share code with Web API
I'm trying to develop an ASP.NET MVC-application with an additional Web API. To reduce code-duplication, I'd like to share as much code as possible, but with the possibility to differentiate between ...
0votes
1answer
114views
API Routes: Get App by User or Get User's App
We have a .Net WebApi 2 we've been working on for quite some time. As we refactor code, we started thinking of what might be a better practice: a) "to get an app by userid", or b) "to ...
4votes
1answer
1kviews
How to authorize and store user login from a xamarin frontend to a asp.net core api
So I suppose this question isn't as much as a 'How to' but a 'which way' kind of question. So I have a .net core api backend that makes calls to a dB I also have a xamarin forms project that ...
-2votes
1answer
409views
How often should I request a token when communicating with a third-party API?
I have an ASP.net web API. I would like to call another API that has an authentication token inside my API. The code flow is as follows: My API is called → Get authentication token from 3rd party API →...
-1votes
1answer
1kviews
Can I call a WCF endpoint from ASP.Net Web API?
I have a web api with controller methods that use rest http(post/get calls). Clients consume this API with normal httpclient calls and I pass an http response back. My use case is I have a legacy ...
41votes
3answers
45kviews
Should we call Web API from MVC application in same solution?
I am working on a project in MVC that has mobile application so one thing is clear that we have to use Web API so it can used in mobile application. After creating API when we started to develop Web ...
8votes
2answers
2kviews
Separation of concerns and other best practices across Controllers, Services, Providers and Stores in ASP.NET when building a REST web api
I am traditionally a desktop app developer, but circumstance has thrust me into the role of doing web client and corresponding REST api logic for a project I am involved in. Unfortunately, I'm a one-...
1vote
4answers
3kviews
Should you validate route parameters or let them fail with a 404?
So this is an example endpoint to fetch one user by its username [HttpGet("{username}")] public async Task<ActionResult<object>> GetUser([FromRoute] string username) { // ... ...
12votes
2answers
19kviews
Should integration tests use database? [closed]
I know that integration tests test parts of project that interaction with each other somehow. And I need to test this interaction. And there is the question: 1)Should these tests use real database ...
7votes
3answers
38kviews
Is it okay to have multiple get action methods in ASP .Net Web API controller according to RESTful API constraints?
I have the following interface in my business layer public interface IUserService { void CreateUser(User user); List<User> FindUsersByName(string searchedString); ...
22votes
2answers
12kviews
Isn't CQRS overengineering?
I still remember good old days of repositories. But repositories used to grow ugly with time. Then CQRS got mainstream. They were nice, they were a breath of fresh air. But recently I've been asking ...
2votes
4answers
7kviews
Web API - How to prevent the POST-ing of entities with custom Id values
Let's say I have the following model: public class Product { public string Id { get; set; } public string Name { get; set; } public string Category { get; set; } public ...
-3votes
1answer
359views
What is the simplest version of best practice application architecture for a backend in C# and ASP.NET Core WebAPI?
I know that in some contexts, best practice would be DDD, CQRS and EventSourcing, but in my case this would be too complicated of two reasons: My team is beginners, and we want them to be productive ...
2votes
2answers
4kviews
ASP.NET Web API and MVC Architecture for Web Application
We have a single solution Visual Studio web application with multiple projects. One of the projects (Services project) has APIs for our App clients (Android/iOS). There's separate project for MVC ...
1vote
2answers
2kviews
Should an ASP.NET Web API application use Entity Framework in the API controllers?
Im a bit confused about what is best practice when working with Entity Framework and ASP.NET Web API. I am working on a project that contains a iOS/Android app and an API the app will use to ...