0

I am having separate projects for view and Business Logic. Now I want to pass the Login credentials and some session values to the BL project. I know I can you Httpcontext.Current but I think it is not possible to unit test the code.

Is there any way to access the session and HttpcontextBase from BL project ?

ekad
  • 13,718
  • 26
  • 42
  • 44
Biju Soman
  • 282
  • 3
  • 15
  • When you want to pass the data from the client to server your able to pass through only request – Aravind Sivam Apr 14 '15 at 06:33
  • you can access HttpContext by referencing it in your BL library – Babak Fakhriloo Apr 14 '15 at 06:41
  • 1
    Kindly reference your BL project to your MVC project. Once referenced, In your method Login (ActionResult), used the passed parameter such username and password, and used that in your BL. /* public ActionResult Login(string username, string password) { //your BL BusinessLogic.MethodName(username, password, other objects); } */ – Chris Apr 14 '15 at 06:43
  • 1
    you can unit test HttpContext: http://stackoverflow.com/questions/9624242/setting-httpcontext-current-session-in-a-unit-test – Mike Debela Apr 14 '15 at 06:45
  • @persianDeveloper Yes , but how can I unit test it ? – Biju Soman Apr 14 '15 at 06:48
  • you can read @MikeDebela `s comment. – Babak Fakhriloo Apr 14 '15 at 06:52
  • You can access the objects, but you shouldnt! just get the actual data out of the session etc as strings or whatever and pass these into your BL layer – Ewan Apr 14 '15 at 07:37

0 Answers0