473,770 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP cookie reading using C#

I have a C# utility that runs in ASP website. when user logs in the
ASP code writes the cookie. I am unable to read it in C# code.

I am using Request.Cookies["cookiename "].Value.ToString ()
I can read the same cookie in ASP code.
If I say Request.Cookies ("CookieName ") in ASP that works fine..
Jun 27 '08 #1
3 2232

<ic********@gma il.comwrote in message
news:20******** *************** ***********@n1g 2000prb.googleg roups.com...
>I have a C# utility that runs in ASP website. when user logs in the
ASP code writes the cookie. I am unable to read it in C# code.

I am using Request.Cookies["cookiename "].Value.ToString ()
I can read the same cookie in ASP code.
If I say Request.Cookies ("CookieName ") in ASP that works fine..
You should post to ms.public.dotne t.framework.asp net.

Jun 27 '08 #2
A page with the below code reads cookies stored on a user's browser.

Hope this may provide solution/idea for your query.
----------------------------------------------------
<%@ language="C#" %>
<script runat="server">
void ReadClicked(Obj ect Sender, EventArgs e)
{
//Get the cookie name the user entered
String strCookieName = NameField.Text;
//Grab the cookie
HttpCookie cookie = Request.Cookies[strCookieName];
//Check to make sure the cookie exists
if (null == cookie)
{
Response.Write( "Cookie not found. <br><hr>");
}
else
{
//Write the cookie value
String strCookieValue = cookie.Value.To String();
Response.Write( "The " + strCookieName + " cookie contains: <b>" + strCookieValue + "</b><br><hr>");
}
}
</script>
<html>
<body>
Use the button below to read a cookie<br>
<form runat="server">
Cookie Name <asp:textbox id="NameField" runat="server" />
<asp:button text="ReadCooki e" onclick="ReadCl icked" runat="server" />
</form>
<a href="writecook ies.aspx">Write Cookies</a>
</body>
</html>
----------------------------------------------------

You can store multiple strings in a cookie using the HttpCookie class. This class have few advanced properties.
Jun 27 '08 #3
Reading a Cookie:

HttpCookie myCookie = new HttpCookie("MyT estCookie");
myCookie = Request.Cookies["MyTestCook ie"];

// Read the cookie information and display it.
if (myCookie != null)
Response.Write( "<p>"+ myCookie.Name + "<p>"+ myCookie.Value) ;
else
Response.Write( "not found");
Refere this link for more info :
http://www.csharphelp.com/archives/archive179.html
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1473
by: Serge | last post by:
Good Day Folks I'm using the following code when creating, reading, and removing a cookies. <% ' writing cookie Response.cookies("OracleLogin")("p_userid")="fcs_system" Response.cookies("OracleLogin")("p_password")="developfcs" 'Response.cookies("OracleLogin").domain="ocdsb.ca" %>
0
1575
by: G R | last post by:
Hi Here is the STEPS/METHOD my service provider sends the calling customer numbers captured : Export Method - HTTP 1. The partner provides Who’s Calling with a URL address to direct the data t the partner 2. Call Sync exports the call record data (XML) HTTP(S) in the Auto-lead Dat Format (ADF) 1.0 3. The partner system receives the data at the desired URL
3
1977
by: R. de Vos | last post by:
Hi all you experts, I have a 'small' problem In a mdb I have a column called "PLACE" its value type = text rowsourcetype=list with values Rowsource = HOME;SCHOOL;STATION What I would like is, one way or the other, to use the items in Rowsource in
3
12005
by: georges the man | last post by:
how do i read from a text file using fread
1
1559
by: 4site | last post by:
Hi all, this is probably stupidly easy but I'm struggling. I am trying to understand why cookies only appear to be readable when a web page is retrieved by *typing the url into the browser's address box* but NOT when the same page is accessed *via a link from another page*. I probably don't fully understand the mechanics of an HTTP request... Example:
3
7771
by: ambrish | last post by:
How can I read any text(PDF/Doc/PPT/rtf/etc.) file using PHP. Ambrish
1
1600
by: shaahid786 | last post by:
hallo, Plz tell me how can i read an Excell File using php code. its very urgent if sombody is on line plz tell me fast.coz i have to work on that. i have already search on diffrent sites but every where i found nothing was up to mark. Regards Ailia Shahid
4
17888
by: boonboy28 | last post by:
I have a BS microcontroller sending data over the serial port to a pc with php. the data is indeed sent as it is displayed within the terminal window. So I have sent and received data over the serial link. But I cannot seem to capture the data using php, all I want to do is capture the data and display it on a web page. I Have used fread, fgets, looked into the uart fifo buffer and also looked into data streams, but there is so much I'm a bit...
1
1430
by: artic | last post by:
Hi all.. I am currently doing a project on Card Reading using Java. I need one help, which package is best to read the card in java?
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.