Server Error in '/' Application. No parameterless constructor defined for this object.How can I resolve this issue. I created one folder in that created interface ICompanyService and class CompanyService.
Controller:
public class HomeController : Controller
{
private ICompanyService icompanyService;
public HomeController(ICompanyService icompanyService)
{
this.icompanyService = icompanyService;
}
public ActionResult Index()
{
ViewBag.CompanyName = this.icompanyService.GetCompany();
return View();
}
}
ICompanyService:
public interface ICompanyService
{
string GetCompany();
}
CompanyService:
public class CompanyService
{
public string GetCompany()
{
return "Msc";
}
}