Where Is IHttpContext Defined?

Last post 07-17-2008 3:56 PM by Luis Abreu. 1 replies.

Sort Posts:

  • Where Is IHttpContext Defined?

    07-17-2008, 1:36 PM
    • Participant
      1,593 point Participant
    • mxmissile
    • Member since 06-19-2002, 10:42 AM
    • Ewtahh
    • Posts 362

     I see it referenced in several articles related to testing routes and MVC stuff in general.  Yet I cannot find it any assembly referenced by my project.  I have the latest MVC stuff referenced (Preview 4).

     Or more specifically, I have a UserService class that depends on HttpContext, how can I test this in a Unit Test project? I am using StructureMap for injection, and I am able to inject it using the HttpContextWrapper as a HttpContextBase, but I cannot get it to work in my Test project. 

     

    This works in the web project, but not the Test project, obviously HttpContext.Current is null.

     

     ForRequestedType().TheDefaultIs(new HttpContextWrapper(HttpContext.Current));
     

     

     

    http://www.heliosfx.com
  • Re: Where Is IHttpContext Defined?

    07-17-2008, 3:56 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    Hello. Use the types defined on the abstractions assembly: http://msmvps.com/blogs/luisabreu/archive/2008/06/03/the-system-web-abstractions.aspx
    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
Page 1 of 1 (2 items)
Microsoft Communities