By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,776 Members | 1,351 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,776 IT Pros & Developers. It's quick & easy.

Detecting if Browser Accepts Cookies & JavaScript

P: n/a
Hello,
In our new intranet ASP.NET project, two requirements are that the browser
accept cookies AND JavaScript. We are requiring the use of Internet
Explorer 6+.

1. Using C# in an ASP.NET application, how can we code the project to check
to make sure the browser accepts cookies?
2. Where would we put this code? In Global.asax?
3. Using C# in an ASP.NET application, how can we code the project to
detect and make sure the browser is configured to run JavaScript?
4. Where would we put this code?

Thanks in advance!
Nov 19 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Use

Request.Browser.Cookies
and
Request.Browser.JavaScript

If the value returned is true, they are enabled.
If false they are not enabled.

PLace it in the login page's Page_Load,
and redirect as appropiate ( maybe to a page
which tells the user that they are a requisite. )

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"SHarris" <sh*****@nospam.com> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
Hello,
In our new intranet ASP.NET project, two requirements are that the browser
accept cookies AND JavaScript. We are requiring the use of Internet
Explorer 6+.

1. Using C# in an ASP.NET application, how can we code the project to
check
to make sure the browser accepts cookies?
2. Where would we put this code? In Global.asax?
3. Using C# in an ASP.NET application, how can we code the project to
detect and make sure the browser is configured to run JavaScript?
4. Where would we put this code?

Thanks in advance!

Nov 19 '05 #2

P: n/a
Thanks Juan! We'll check it out.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
Use

Request.Browser.Cookies
and
Request.Browser.JavaScript

If the value returned is true, they are enabled.
If false they are not enabled.

PLace it in the login page's Page_Load,
and redirect as appropiate ( maybe to a page
which tells the user that they are a requisite. )

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"SHarris" <sh*****@nospam.com> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
Hello,
In our new intranet ASP.NET project, two requirements are that the browser accept cookies AND JavaScript. We are requiring the use of Internet
Explorer 6+.

1. Using C# in an ASP.NET application, how can we code the project to
check
to make sure the browser accepts cookies?
2. Where would we put this code? In Global.asax?
3. Using C# in an ASP.NET application, how can we code the project to
detect and make sure the browser is configured to run JavaScript?
4. Where would we put this code?

Thanks in advance!


Nov 19 '05 #3

P: n/a
The standard way of doing this is by using
"the proof is in the pudding" programming.

If testing for cookies, issue a cookie and read it
after a redirect. If it's there, fine. If not...you know.

The same for JavaScript.
Set a variable, and test for it later in the page..

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"SHarris" <sh*****@nospam.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
Thanks Juan! We'll check it out.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
Use

Request.Browser.Cookies
and
Request.Browser.JavaScript

If the value returned is true, they are enabled.
If false they are not enabled.

PLace it in the login page's Page_Load,
and redirect as appropiate ( maybe to a page
which tells the user that they are a requisite. )

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"SHarris" <sh*****@nospam.com> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
> Hello,
> In our new intranet ASP.NET project, two requirements are that the browser > accept cookies AND JavaScript. We are requiring the use of Internet
> Explorer 6+.
>
> 1. Using C# in an ASP.NET application, how can we code the project to
> check
> to make sure the browser accepts cookies?
> 2. Where would we put this code? In Global.asax?
> 3. Using C# in an ASP.NET application, how can we code the project to
> detect and make sure the browser is configured to run JavaScript?
> 4. Where would we put this code?
>
> Thanks in advance!
>
>



Nov 19 '05 #4

P: n/a
Again, thanks for the info. But, after reviewing Request.Browser.Cookies
and Request.Browser.JavaScript, these two properties simply return true if
browser client "supports" Cookies and JavaScript, respectively. This is
good to know.

But, what we really need is a way to check and make sure the user has not
disabled Cookies and JavaScript through security settings. Any thoughts?
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ej**************@tk2msftngp13.phx.gbl...
Use

Request.Browser.Cookies
and
Request.Browser.JavaScript

If the value returned is true, they are enabled.
If false they are not enabled.

PLace it in the login page's Page_Load,
and redirect as appropiate ( maybe to a page
which tells the user that they are a requisite. )

Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"SHarris" <sh*****@nospam.com> wrote in message
news:eh**************@TK2MSFTNGP14.phx.gbl...
Hello,
In our new intranet ASP.NET project, two requirements are that the browser accept cookies AND JavaScript. We are requiring the use of Internet
Explorer 6+.

1. Using C# in an ASP.NET application, how can we code the project to
check
to make sure the browser accepts cookies?
2. Where would we put this code? In Global.asax?
3. Using C# in an ASP.NET application, how can we code the project to
detect and make sure the browser is configured to run JavaScript?
4. Where would we put this code?

Thanks in advance!


Nov 19 '05 #5

P: n/a
to tell if cookies are enabled, set a cookie value, and redirect to a page
that checks if the cookie is set.

to tell if javascript is enabled: try:

<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="1;
URL=http://yoursite.com/vir/jtest.aspx">
</head>
<body>
<form>
<input type=hidden id=jtest name=jtest value="no">
<script>document.getElementById('jtest').value="ye s";document.forms[0].submi
t();<script>
</form>
if this page does not refresh automatically, click <a
href="nometarefresh.aspx">here</a>
</body>
</html>

-- bruce (sqlwork.com)

"SHarris" <sh*****@nospam.com> wrote in message
news:O9**************@TK2MSFTNGP14.phx.gbl...
| Again, thanks for the info. But, after reviewing Request.Browser.Cookies
| and Request.Browser.JavaScript, these two properties simply return true if
| browser client "supports" Cookies and JavaScript, respectively. This is
| good to know.
|
| But, what we really need is a way to check and make sure the user has not
| disabled Cookies and JavaScript through security settings. Any thoughts?
|
|
| "Juan T. Llibre" <no***********@nowhere.com> wrote in message
| news:ej**************@tk2msftngp13.phx.gbl...
| > Use
| >
| > Request.Browser.Cookies
| > and
| > Request.Browser.JavaScript
| >
| > If the value returned is true, they are enabled.
| > If false they are not enabled.
| >
| > PLace it in the login page's Page_Load,
| > and redirect as appropiate ( maybe to a page
| > which tells the user that they are a requisite. )
| >
| >
| >
| > Juan T. Llibre
| > ASP.NET MVP
| > http://asp.net.do/foros/
| > Foros de ASP.NET en Español
| > =====================
| >
| > "SHarris" <sh*****@nospam.com> wrote in message
| > news:eh**************@TK2MSFTNGP14.phx.gbl...
| > > Hello,
| > > In our new intranet ASP.NET project, two requirements are that the
| browser
| > > accept cookies AND JavaScript. We are requiring the use of Internet
| > > Explorer 6+.
| > >
| > > 1. Using C# in an ASP.NET application, how can we code the project to
| > > check
| > > to make sure the browser accepts cookies?
| > > 2. Where would we put this code? In Global.asax?
| > > 3. Using C# in an ASP.NET application, how can we code the project to
| > > detect and make sure the browser is configured to run JavaScript?
| > > 4. Where would we put this code?
| > >
| > > Thanks in advance!
| > >
| > >
| >
| >
|
|
Nov 19 '05 #6

P: n/a
Why is a redirection alleged to be required?

--
<%= Clinton Gallagher
METROmilwaukee "Regional Information Services"
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
to tell if cookies are enabled, set a cookie value, and redirect to a page
that checks if the cookie is set.

to tell if javascript is enabled: try:

<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="1;
URL=http://yoursite.com/vir/jtest.aspx">
</head>
<body>
<form>
<input type=hidden id=jtest name=jtest value="no">
<script>document.getElementById('jtest').value="ye s";document.forms[0].submi t();<script>
</form>
if this page does not refresh automatically, click <a
href="nometarefresh.aspx">here</a>
</body>
</html>

-- bruce (sqlwork.com)

"SHarris" <sh*****@nospam.com> wrote in message
news:O9**************@TK2MSFTNGP14.phx.gbl...
| Again, thanks for the info. But, after reviewing Request.Browser.Cookies | and Request.Browser.JavaScript, these two properties simply return true if | browser client "supports" Cookies and JavaScript, respectively. This is
| good to know.
|
| But, what we really need is a way to check and make sure the user has not | disabled Cookies and JavaScript through security settings. Any thoughts? |
|
| "Juan T. Llibre" <no***********@nowhere.com> wrote in message
| news:ej**************@tk2msftngp13.phx.gbl...
| > Use
| >
| > Request.Browser.Cookies
| > and
| > Request.Browser.JavaScript
| >
| > If the value returned is true, they are enabled.
| > If false they are not enabled.
| >
| > PLace it in the login page's Page_Load,
| > and redirect as appropiate ( maybe to a page
| > which tells the user that they are a requisite. )
| >
| >
| >
| > Juan T. Llibre
| > ASP.NET MVP
| > http://asp.net.do/foros/
| > Foros de ASP.NET en Español
| > =====================
| >
| > "SHarris" <sh*****@nospam.com> wrote in message
| > news:eh**************@TK2MSFTNGP14.phx.gbl...
| > > Hello,
| > > In our new intranet ASP.NET project, two requirements are that the
| browser
| > > accept cookies AND JavaScript. We are requiring the use of Internet
| > > Explorer 6+.
| > >
| > > 1. Using C# in an ASP.NET application, how can we code the project to | > > check
| > > to make sure the browser accepts cookies?
| > > 2. Where would we put this code? In Global.asax?
| > > 3. Using C# in an ASP.NET application, how can we code the project to | > > detect and make sure the browser is configured to run JavaScript?
| > > 4. Where would we put this code?
| > >
| > > Thanks in advance!
| > >
| > >
| >
| >
|
|

Nov 19 '05 #7

P: n/a
You can't set a cookie and read it without
the client going back to the server ?

Back in the "classic asp" days, I used a workaround
which "tricked" you into believing it was the same page,
but what happened was that I'd set the setting cookie
in a 0 pixel display frame, and read it in the first page
the client saw, but that was just sleight of hand.

I suppose you could set a cookie in Session_OnStart,
but to retrieve it, wouldn't you need for the client to go
back to the server ?

Why do you say "alleged" ? How would you do it ?
( Without a second page being called ? )


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Why is a redirection alleged to be required?
<%= Clinton Gallagher
"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
to tell if cookies are enabled, set a cookie value, and redirect to a
page
that checks if the cookie is set.

to tell if javascript is enabled: try:

<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="1;
URL=http://yoursite.com/vir/jtest.aspx">
</head>
<body>
<form>
<input type=hidden id=jtest name=jtest value="no">

<script>document.getElementById('jtest').value="ye s";document.forms[0].submi
t();<script>
</form>
if this page does not refresh automatically, click <a
href="nometarefresh.aspx">here</a>
</body>
</html>

-- bruce (sqlwork.com)

"SHarris" <sh*****@nospam.com> wrote in message
news:O9**************@TK2MSFTNGP14.phx.gbl...
| Again, thanks for the info. But, after reviewing

Request.Browser.Cookies
| and Request.Browser.JavaScript, these two properties simply return true

if
| browser client "supports" Cookies and JavaScript, respectively. This
is
| good to know.
|
| But, what we really need is a way to check and make sure the user has

not
| disabled Cookies and JavaScript through security settings. Any

thoughts?
|
|
| "Juan T. Llibre" <no***********@nowhere.com> wrote in message
| news:ej**************@tk2msftngp13.phx.gbl...
| > Use
| >
| > Request.Browser.Cookies
| > and
| > Request.Browser.JavaScript
| >
| > If the value returned is true, they are enabled.
| > If false they are not enabled.
| >
| > PLace it in the login page's Page_Load,
| > and redirect as appropiate ( maybe to a page
| > which tells the user that they are a requisite. )
| >
| >
| >
| > Juan T. Llibre
| > ASP.NET MVP
| > http://asp.net.do/foros/
| > Foros de ASP.NET en Español
| > =====================
| >
| > "SHarris" <sh*****@nospam.com> wrote in message
| > news:eh**************@TK2MSFTNGP14.phx.gbl...
| > > Hello,
| > > In our new intranet ASP.NET project, two requirements are that the
| browser
| > > accept cookies AND JavaScript. We are requiring the use of
Internet
| > > Explorer 6+.
| > >
| > > 1. Using C# in an ASP.NET application, how can we code the project

to
| > > check
| > > to make sure the browser accepts cookies?
| > > 2. Where would we put this code? In Global.asax?
| > > 3. Using C# in an ASP.NET application, how can we code the project

to
| > > detect and make sure the browser is configured to run JavaScript?
| > > 4. Where would we put this code?
| > >
| > > Thanks in advance!
| > >
| > >
| >
| >
|
|


Nov 19 '05 #8

P: n/a
Poor choice of words Juan.

I've been wondering if there is an optimal way to do detection without using
redirection to avoid being penalized or banned by Google and other search
engines.

We've been wanting to load domain.com/appname/default.aspx and do utility
functions such as detection in the default.aspx and then redirect to
appname.aspx but don't know if this would result in getting slapped by
Google.

<%= Clinton Gallagher

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
You can't set a cookie and read it without
the client going back to the server ?

Back in the "classic asp" days, I used a workaround
which "tricked" you into believing it was the same page,
but what happened was that I'd set the setting cookie
in a 0 pixel display frame, and read it in the first page
the client saw, but that was just sleight of hand.

I suppose you could set a cookie in Session_OnStart,
but to retrieve it, wouldn't you need for the client to go
back to the server ?

Why do you say "alleged" ? How would you do it ?
( Without a second page being called ? )


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Why is a redirection alleged to be required?
<%= Clinton Gallagher


"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
to tell if cookies are enabled, set a cookie value, and redirect to a
page
that checks if the cookie is set.

to tell if javascript is enabled: try:

<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="1;
URL=http://yoursite.com/vir/jtest.aspx">
</head>
<body>
<form>
<input type=hidden id=jtest name=jtest value="no">

<script>document.getElementById('jtest').value="ye s";document.forms[0].submi
t();<script>
</form>
if this page does not refresh automatically, click <a
href="nometarefresh.aspx">here</a>
</body>
</html>

-- bruce (sqlwork.com)

"SHarris" <sh*****@nospam.com> wrote in message
news:O9**************@TK2MSFTNGP14.phx.gbl...
| Again, thanks for the info. But, after reviewing

Request.Browser.Cookies
| and Request.Browser.JavaScript, these two properties simply return true
if
| browser client "supports" Cookies and JavaScript, respectively. This
is
| good to know.
|
| But, what we really need is a way to check and make sure the user has

not
| disabled Cookies and JavaScript through security settings. Any

thoughts?
|
|
| "Juan T. Llibre" <no***********@nowhere.com> wrote in message
| news:ej**************@tk2msftngp13.phx.gbl...
| > Use
| >
| > Request.Browser.Cookies
| > and
| > Request.Browser.JavaScript
| >
| > If the value returned is true, they are enabled.
| > If false they are not enabled.
| >
| > PLace it in the login page's Page_Load,
| > and redirect as appropiate ( maybe to a page
| > which tells the user that they are a requisite. )
| >
| >
| >
| > Juan T. Llibre
| > ASP.NET MVP
| > http://asp.net.do/foros/
| > Foros de ASP.NET en Español
| > =====================
| >
| > "SHarris" <sh*****@nospam.com> wrote in message
| > news:eh**************@TK2MSFTNGP14.phx.gbl...
| > > Hello,
| > > In our new intranet ASP.NET project, two requirements are that
the | browser
| > > accept cookies AND JavaScript. We are requiring the use of
Internet
| > > Explorer 6+.
| > >
| > > 1. Using C# in an ASP.NET application, how can we code the

project to
| > > check
| > > to make sure the browser accepts cookies?
| > > 2. Where would we put this code? In Global.asax?
| > > 3. Using C# in an ASP.NET application, how can we code the
project to
| > > detect and make sure the browser is configured to run JavaScript?
| > > 4. Where would we put this code?
| > >
| > > Thanks in advance!
| > >
| > >
| >
| >
|
|



Nov 19 '05 #9

P: n/a
Poor choice of words Juan.

I've been wondering if there is an optimal way to do detection without using
redirection to avoid being penalized or banned by Google and other search
engines.

We've been wanting to load domain.com/appname/default.aspx and do utility
functions such as detection in the default.aspx and then redirect to
appname.aspx but don't know if this would result in getting slapped by
Google.

<%= Clinton Gallagher

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...
You can't set a cookie and read it without
the client going back to the server ?

Back in the "classic asp" days, I used a workaround
which "tricked" you into believing it was the same page,
but what happened was that I'd set the setting cookie
in a 0 pixel display frame, and read it in the first page
the client saw, but that was just sleight of hand.

I suppose you could set a cookie in Session_OnStart,
but to retrieve it, wouldn't you need for the client to go
back to the server ?

Why do you say "alleged" ? How would you do it ?
( Without a second page being called ? )


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
=====================

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:OB**************@tk2msftngp13.phx.gbl...
Why is a redirection alleged to be required?
<%= Clinton Gallagher


"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
to tell if cookies are enabled, set a cookie value, and redirect to a
page
that checks if the cookie is set.

to tell if javascript is enabled: try:

<html>
<head>
<META HTTP-EQUIV=Refresh CONTENT="1;
URL=http://yoursite.com/vir/jtest.aspx">
</head>
<body>
<form>
<input type=hidden id=jtest name=jtest value="no">

<script>document.getElementById('jtest').value="ye s";document.forms[0].submi
t();<script>
</form>
if this page does not refresh automatically, click <a
href="nometarefresh.aspx">here</a>
</body>
</html>

-- bruce (sqlwork.com)

"SHarris" <sh*****@nospam.com> wrote in message
news:O9**************@TK2MSFTNGP14.phx.gbl...
| Again, thanks for the info. But, after reviewing

Request.Browser.Cookies
| and Request.Browser.JavaScript, these two properties simply return true
if
| browser client "supports" Cookies and JavaScript, respectively. This
is
| good to know.
|
| But, what we really need is a way to check and make sure the user has

not
| disabled Cookies and JavaScript through security settings. Any

thoughts?
|
|
| "Juan T. Llibre" <no***********@nowhere.com> wrote in message
| news:ej**************@tk2msftngp13.phx.gbl...
| > Use
| >
| > Request.Browser.Cookies
| > and
| > Request.Browser.JavaScript
| >
| > If the value returned is true, they are enabled.
| > If false they are not enabled.
| >
| > PLace it in the login page's Page_Load,
| > and redirect as appropiate ( maybe to a page
| > which tells the user that they are a requisite. )
| >
| >
| >
| > Juan T. Llibre
| > ASP.NET MVP
| > http://asp.net.do/foros/
| > Foros de ASP.NET en Español
| > =====================
| >
| > "SHarris" <sh*****@nospam.com> wrote in message
| > news:eh**************@TK2MSFTNGP14.phx.gbl...
| > > Hello,
| > > In our new intranet ASP.NET project, two requirements are that
the | browser
| > > accept cookies AND JavaScript. We are requiring the use of
Internet
| > > Explorer 6+.
| > >
| > > 1. Using C# in an ASP.NET application, how can we code the

project to
| > > check
| > > to make sure the browser accepts cookies?
| > > 2. Where would we put this code? In Global.asax?
| > > 3. Using C# in an ASP.NET application, how can we code the
project to
| > > detect and make sure the browser is configured to run JavaScript?
| > > 4. Where would we put this code?
| > >
| > > Thanks in advance!
| > >
| > >
| >
| >
|
|



Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.