[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Can a .NET page read a cookie written by an html page?

Posted on 2016-08-20
Medium Priority
Last Modified: 2016-08-20
I am writing a cookie via javascript from within a basic HTML page, to indicate that the user is logged in.
There is another page on the site that is written in ASP.NET, which needs to know whether the user is logged in.
Is it possible for an ASP.NET page to read a cookie written by an HTML page? Or can .NET pages only read cookies written by other .NET pages?
Question by:rascal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

bas2754 earned 1000 total points
ID: 41763841
Old post from here outlines the steps:

Summary of the answer from that page:
            Dim UserResolution As String
            If Request.Cookies("Screen") IsNot Nothing Then
                Dim TheCookie As HttpCookie = Request.Cookies("Screen")
                UserResolution = Server.HtmlEncode(TheCookie.Value)
                UserResolution = "NA"
            End If

Open in new window

Basically you just substitue the name of your cookie for the "Screen" variable written above and it should work for you.  Read through the page for more info, but I do know it works as I have done it as well, I just don't have access to the code right now to give you the examples I have done.
LVL 83

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 500 total points
ID: 41763855
A qualified yes.. getting the details right is the hard part.
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 41763878
In cookies, the domain name must be an exact text match.  'www.domain.com' is Not the same as 'domain.com' in cookies.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question