Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229818
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:51:17+00:00 2026-05-17T16:51:17+00:00

Visual Studio 2010 seems to be mixing up the above mentioned libraries. This code

  • 0

Visual Studio 2010 seems to be mixing up the above mentioned libraries.

This code sample is from the book “Pro ASP.NET MVC2 Framework” by Steven Sanderson.

[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 is only “using System.Web” I get two errors:

  1. (Line 25 under the word ‘Assert’) The type ‘System.Web.HttpResponseBase’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’.
  2. (Lines 25 and 26 under the word ‘Cookies’) ‘System.Web.HttpResponseBase’ does not contain a definition for ‘Cookies’ and no extension method ‘Cookies’ accepting a first argument of type ‘System.Web.HttpResponseBase’ could be found (are you missing a using directive or an assembly reference?)

If I add “using System.Web.Abstractions” to the code file and build the project, the above errors go away but then then I get the following error:

  1. The type or namespace name ‘Abstractions’ does not exist in the namespace ‘System.Web’ (are you missing an assembly reference?)

Interestingly, in both cases when I place a dot after Response, Intellisense prompts me with the correct choices (i.e. Response.Cookies). It seems like Intellisense has information about HttpResponseBase that the build engine does not.

Any idea what may be causing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:51:18+00:00Added an answer on May 17, 2026 at 4:51 pm

    Can you double check that under your Project References you have both System.Web and System.Web.Abstractions?

    Using the source code for the book downloaded from the Apress site, I can build your code without errors, but when I remove the reference to System.Web.Abstractions, I get the same behavior, including the intellisense information prompts you noted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.