Hi everyone,
I have stumbled upon a weird scenario using custom routes.
I have created an attribute route component
public class AttributeRoutingComponent : IComponent
{
public void Initialize()
{
GlobalConfiguration.Configuration.MapHttpAttributeRoutes();
}
public void Terminate()
{
}
}
Which is added in my bootstrapper
public void Compose(Composition composition)
{
DependencyInjectionConfiguration.SetupDependencyInjection(composition);
composition.Components().Append<AttributeRoutingComponent>();}
I have several routes which are all working just fine. I have one route which creates content in a seperate database. I wanted to return the route at which this content can be retrieved using the "CreatedAtRoute", this means that my get route needs to have a route name. As soon as I add the "Name" part of the route, Umbraco CMS throws a hissyfit and won't start. My APIs work just fine through postman, but Umbraco CMS, not so much.
[Route("applicationTypes/{applicationTypeId}/applications")]
[HttpPost]
public async Task<IHttpActionResult> AddApplication([FromUri] Guid applicationTypeId, [FromBody] dynamic json)
{
var responseId = await _databaseService.AddApplication(applicationTypeId, json);
return CreatedAtRoute("GetApplicationById", new { applicationTypeId, applicationId = responseId }, "Application successfully added");
}
[Route("applicationTypes/{applicationTypeId}/applications/{applicationId}", Name = "GetApplicationById")]
[HttpGet]
public async Task<IHttpActionResult> GetApplication([FromUri] Guid applicationTypeId, int applicationId)
{
var application = await _databaseService.GetApplication(applicationId);
return Ok(application);
}
If I name my route the GetApplicationById as above I clearly get an error stating that that name is already taken. But if I name it something random I get a weird error, that doesn't really tell me much
Custom Route Name causing Umbraco to fail
Hi everyone, I have stumbled upon a weird scenario using custom routes. I have created an attribute route component
Which is added in my bootstrapper
I have several routes which are all working just fine. I have one route which creates content in a seperate database. I wanted to return the route at which this content can be retrieved using the "CreatedAtRoute", this means that my get route needs to have a route name. As soon as I add the "Name" part of the route, Umbraco CMS throws a hissyfit and won't start. My APIs work just fine through postman, but Umbraco CMS, not so much.
If I name my route the GetApplicationById as above I clearly get an error stating that that name is already taken. But if I name it something random I get a weird error, that doesn't really tell me much
Does anyone have an idea?
is working on a reply...