Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 1288 posts 3921 karma points c-trib
    Aug 31, 2010 @ 12:09
    Dan
    0

    Namespace reference to use for 'UmbracoContext.Current.Response.Cookies'

    Hi,

    This is following on from an earlier thread but the issue has evolved a little.  Basically, I have this code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using umbraco;
    using umbraco.presentation;

    namespace myproject
    {
    public partial class SetCookie : System.Web.UI.UserControl
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (library.IsLoggedOn()) {
    Label1.Text = "Logged in";
    } else {
    if (string.IsNullOrEmpty(UmbracoContext.Current.Request.Cookies["visitorGUID"].Value))
    {
    Guid myguid = Guid.NewGuid();
    UmbracoContext.Current.Response.Cookies["visitorGUID"].Value = myguid.ToString();
    }
    }

    }
    }
    }

    However, when I try to build it, it errors, saying "You must add a reference to assembly 'System.Web.Abstractions'".  I've tried adding the namespace reference System.Web.Abstractions but it in turn errors saying "The type or namespace name 'Abstractions' does not exist in the namespace 'System.Web'".  Seems like I can't win ;)

    Does anyone know what namespaces to reference in order to get this to work, or is there a more fundamental problem?

    Thanks all.

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 31, 2010 @ 14:28
    Aaron Powell
    0

    You need to reference the System.Web.Abstractions assembly in your project.

    UmbracoContext uses the abstract implementation of the Http* objects, which were initially written for ASP.NET MVC

  • Dan 1288 posts 3921 karma points c-trib
    Aug 31, 2010 @ 14:54
    Dan
    0

    Thanks Slace, I've now added 'System.Web.Absctractions' to the references folder in my project, and added the reference in the code-behind page again, and it still errors: "Error    3    The type or namespace name 'Abstractions' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)".  Is there a dependency on another namespace, or do I need to somehow refresh the project to make that assembly open to reference now?

    I'm probably doing something blindingly obviously wrong, but I'm a noob at all this, so your patience is appreciated!

    Cheers

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 01, 2010 @ 00:35
    Aaron Powell
    0

    Are you using .NET 3.5 or .NET 4.0?

    Did you ensure you referenced the correct version of the assembly for the runtime type?

Please Sign in or register to post replies

Write your reply to:

Draft