I'm new to the ASP.NET MVC 5 and WebAPI 2 technology. I am currently developing a web service for my desktop application.
I have developed the web service with individual user account authentication in asp.net mvc 5 web API 2. I refer link :- " http://vod.com.ng/en/video/KyxcLfz_CW8/8-Authenticated-WebAPI-ASPNET-MVC-5-Fundamentals-5-WebAPI-2 ". It helped me but I need to add layers in project i.e. WEB and CORE.
I shifted "AccountBindingModels.cs" and "AccountViewModels.cs" from Models folder in WEB to POCO folder in CORE, after running the program I am getting error " POST /api/account/register 500 (Internal Server Error) " and " An error occurred when trying to create a controller of type 'AccountController' ".
I want to add api controllers and model classes which will be authenticated by the individual user account. Please help. Let me know what else you need to know. Thanks in advance.
CODE from UnityConfig.cs file
public static void RegisterTypes(IUnityContainer container)
{
container.RegisterType(typeof(IRepository<>), typeof(Repository<>));
container.RegisterType(typeof(DbContext), typeof(DataContext));
}
Controller
namespace DesktopApp.Controllers
{
public class StudentLoginController : ApiController
{
private IRepository<StudentLogin> _StudentLoginRepository;
public StudentLoginController(IRepository<StudentLogin> StudentLoginRepository)
{
_StudentLoginRepository = StudentLoginRepository;
}
[HttpPost]
[Route("api/StudentLogin/Post")]
public StudentLogin Post(StudentLogin loginData)
{
var studentLoginDetails = _StudentLoginRepository.GetAll().Where(p => p.studentName == loginData.studentName && p.studentPassword == loginData.studentPassword).FirstOrDefault<StudentLogin>();
return studentLoginDetails;
}