Why is Visual Studio 2010 mixing System.Web and System.Web.Abstractions?

Visual Studio 2010 seems to be mixing the above libraries.

This sample code is from Stephen Sanderson's About ASP.NET MVC2 Framework.

[TestMethod]
public void HomePage_Recognizes_New_Visitor_And_Sets_Cookie() 
{
    // Arrange: First prepare some mock context objects
    var mockContext = new Mock<HttpContextBase>();
    var mockRequest = new Mock<HttpRequestBase>();
    var mockResponse = new Mock<HttpResponseBase>();

    // The following lines define associations between the different mock objects
    // (i.e. tells Moq what alue to use for tMockContext.Request)
    mockContext.Setup(x=> x.Request).Returns(mockRequest.Object);
    mockContext.Setup(x=> x.Response).Returns(mockResponse.Object);
    mockRequest.Setup(x=> x.Cookies).Returns(new HttpCookieCollection());
    mockResponse.Setup(x=> x.Cookies).Returns(new HttpCookieCollection());

    var homeController = new HomeController();
    var requestContext = new RequestContext(mockContext.Object, new RouteData());
    homeController.ControllerContext = new ControllerContext(requestContext, homeController);

    // Act
    ViewResult viewResult = homeController.HomePage();

    // Assert
    Assert.AreEqual(String.Empty, viewResult.ViewName);
    Assert.IsTrue((bool)viewResult.ViewData["IsFirstVisit"]);
    Assert.AreEqual(1, homeController.Response.Cookies.Count);
    Assert.AreEqual(bool.TrueString, homeController.Response.Cookies["HasVisitedBefore"].Value);
}

My project references the System.Web and System.Web.Abstractions libraries.

When the code file only "uses System.Web", I get two errors:

  • (line 25 under the word "Assert") The type "System.Web.HttpResponseBase" is defined in an assembly that is not referenced. You should add a link to the assembly "System.Web.Abstractions, Version = 3.5.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35".
  • ( 25 26 "Cookies" ) "System.Web.HttpResponseBase" "Cookies" "Cookies" , "System.Web.HttpResponseBase '( ?)

"using System.Web.Abstractions" , , :

  • "" "System.Web" ( ?)

, , , Intellisense (.. Response.Cookies). , Intellisense HttpResponseBase, .

, ?

+5
2

, System.Web, System.Web.Abstractions?

, Apress, , System.Web.Abstractions, , intellisense, .

+7

, (HttpContextWrapper ) System.Web.Abstractions, System.Web( using ).

using System.Web , ( ) System.Web.Abstractions, .

+4

All Articles