Last active
March 14, 2019 20:25
-
-
Save ornerymoose/1f7d152646ca36b2f88079842a495c39 to your computer and use it in GitHub Desktop.
if I set a breakpoint on this method and go to localhost:1234/api/employee, the breakpoint will be hit. If I try to do localhost:1234/api/employee/SOME_ID it'll 404. What am I overlooking here?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.Web.Http; | |
using MyApp.ElasticData; | |
using MyApp.Models; | |
namespace MyApp.Controllers | |
{ | |
public class EmployeeController : BaseController | |
{ | |
[Route("api/employee")] | |
[HttpGet] | |
public async Task<Employee> GetByPernr(string id = null) | |
{ | |
var app = new ElasticEvents(); | |
var emp = await app.GetElasticDataById(id); | |
var empData = new Employee | |
{ | |
FirstName = emp.FirstName, | |
LastName = emp.LastName, | |
NtId = emp.NtId | |
}; | |
return empData; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void RegisterRoutes(RouteCollection routes) | |
{ | |
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | |
routes.LowercaseUrls = true; | |
routes.MapRoute( | |
"Default", // Route name | |
"{controller}/{action}/{id}", // URL with parameters | |
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment