Read/Write cookies in WebMatrix3 RRS feed

  • Question

  • User233633862 posted


    I am trying to use the Request.Cookies("Cookiename") , Response.Cookies.Add(Cookiename) and Server.HtmlEncode(Request.Cookies("Cookiename) methods but get the following error,

    'Compiler Error Message: BC30451: 'Request' is not declared. It may be inaccessible due to its protection level .

    The detailed compiler report is idenfifying 'Request', 'Response' and 'Server' with this error. Can anyone say what I am doing wrong?, the following imports are shown on the complete compilation source.


    Imports DotNetOpenAuth.AspNet

    Imports Microsoft.Web.Helpers

    Imports Microsoft.Web.WebPages.OAuth

    Imports System

    Imports System.Collections.Generic

    Imports System.IO

    Imports System.Linq

    Imports System.Net

    Imports System.Web

    Imports System.Web Line

    Imports System.Web.Helpers

    Imports System.Web.Security

    Imports System.Web.UI

    Imports System.Web.WebPages

     Imports System.Web.WebPages.Html

    Imports WebMatrix.Data

    Imports WebMatrix.WebData

    Many Thanks


    Thursday, August 1, 2013 4:58 PM


All replies

  • User1287173004 posted

    Request.Cookies["Cookiename"]   square brackets

    Thursday, August 1, 2013 9:18 PM
  • User233633862 posted

    I am using vb not C#, it will not accept [ ] only ( ) in the command. I think it is an issue with a missing Import, can anyone identify which Import provides access to the Request, Response and System methods for dealing with cookies.



    Friday, August 2, 2013 5:07 AM
  • User1287173004 posted

    Try posting here


    Friday, August 2, 2013 8:19 AM
  • User233633862 posted

    Hi wavemaster,

    I found something in this forum which indicates these calls do not always work when called from the _AppStart page, which is where I was trying to use them. Re-locatting them to another page now removes the compiler errors, I am still trying to undertand how to use cookies etc. etc. but at least the site will run.

    Thanks for your interest.


    Friday, August 2, 2013 9:51 AM
  • User1183424175 posted


    Try using HttpContext.Current.Request. And please refer the similar thread


    Hope it can help you

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Saturday, August 3, 2013 4:13 AM