0

I have something very very strange. I have 2 controllers. UploadController and AccountController. Theye were both working, and now when I try the AccountController it give error 404. ik don't get it.

This is how my AccountController looks like:

namespace CoreAngular.Controllers { //[Authorize] [Produces("application/json")] [Route("api/account")] public class AccountController : Controller { private IRepository repository; public AccountController(IDatabaseClient<DocumentClient> client) : this ( new UserRepository(client)) { } public AccountController(IRepository repository) { this.repository = repository; } [HttpGet] public async Task<ActionResult> Get(string id) { var start = DateTime.Now.TimeOfDay; if (string.IsNullOrEmpty(id)) { return BadRequest(); } var user = await repository.GetAsync(id); if (user == null) { return NotFound(); } var userDTO = new UserGetDTO() { image = Convert.ToBase64String(user.image.image), id = user.id, time = DateTime.Now.Subtract(start).Millisecond }; return Ok(userDTO); }...... 

Do I miss something here? I know I comentet out the [Authorize], but i just wanted to try to connect.

4
  • Which url do you use for calling controller action? Commented Dec 18, 2017 at 14:23
  • I use this url: localhost:50331/api/account{{ID}} Commented Dec 18, 2017 at 14:27
  • You miss a slash between account and id, don't you? The url should be like localhost:50331/api/account/SomeId Commented Dec 18, 2017 at 14:49
  • Yes sorry I have the slash, but typed to fast Commented Dec 18, 2017 at 15:47

1 Answer 1

1

You should specify route template in HttpGet attribute:

[HttpGet("{id}")] public async Task<ActionResult> Get(string id) { // ... } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.