'Gives Internal Server Error while trying to access to the contoller
I trying to access my Rental Controller but it gives me internal error. It was working fine before some changes ( i don't rememember them).Also other controllers(e.g BrandController) are working fine now.
RentalsController
[Route("api/[controller]")]
[ApiController]
public class RentalsController : ControllerBase
{
private readonly IRentalService _rentalService;
public RentalsController(IRentalService rentalService)
{
_rentalService = rentalService;
}
[HttpGet("getall")]
public IActionResult GetAll()
{
var result = _rentalService.GetAllRentals();
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
BrandsController
[Route("api/[controller]")]
[ApiController]
public class BrandsController : ControllerBase
{
private readonly IBrandService _brandService;
public BrandsController(IBrandService brandService)
{
_brandService = brandService;
}
[HttpGet("getall")]
public IActionResult GetAll()
{
var result = _brandService.GetAllBrands();
if (result.Success)
{
return Ok(result);
}
return BadRequest(result);
}
AutofacBusinessModule
public class AutofacBusinessModule :Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<BrandManager>().As<IBrandService>().SingleInstance();
builder.RegisterType<EfBrandDal>().As<IBrandDal>().SingleInstance();
builder.RegisterType<RentalManager>().As<IRentalService>().SingleInstance();
builder.RegisterType<EfRentalDal>().As<IRentalDal>().SingleInstance();
Update
When i trigger thewhen I triggered the function, the output gives an error as follows.
Output
The thread 0x1b64 has exited with code 0 (0x0).
Exception thrown: 'Autofac.Core.DependencyResolutionException' in System.Private.CoreLib.dll
The thread 0x3780 has exited with code 0 (0x0).
The thread 0x4cbc has exited with code 0 (0x0).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

