Posted on 02/11/2020 12:57:40
Hi Lars,
We had to remove alot of our direct usage of things like HttpApplication in our push towards .Net Core, so this is one of those things that had to change.
Luckily you can fairly easily access the correct information, but instead of using the property from myArgs, you can access HttpContext.Current.Application.Context (or just use HttpContext.Current ?). Anyway, try it out and give me an update on the progress?
I don't know exactly what kind of routes you're trying to add for the component (or why), but if it's to register webapi endpoints with corresponding methods that return values, it's probably easier to do something like this:
using System.Web.Http;
[RoutePrefix("api/products")]
public class ProductsController : ApiController
{
[HttpGet, Route("")] // api/products
public IHttpActionResult GetAll() { return Ok([valueThatShouldBeReturned])}//note that this also handles things like status-code (here it's 200, but you can easily return an error-status if you catch an exception)
[HttpGet, Route("{IdName}")]// api/products/valueOfMyId
public IHttpActionResult GetById(string idName) { [...]} //note that the parameter name should match the literal in the Route attribute
}
This way it's easy to read what method belongs to a specific route and what type it is.
BR
Martin