Home All Groups Group Topic Archive Search About

Is there a way to detect user screen resolution in server side code?

Author
10 Jun 2005 10:03 AM
Bredahl jensen
Most of the the solution i have seen was throught javascript.


Many thanks in advance


JB

Author
10 Jun 2005 10:22 AM
John Timney (ASP.NET MVP)
There is no connection between the server and the client other than when a
request is made - so javascript would be the most appropriate way.  There is
a server side class called the  HttpBrowserCapabilities Class but it only
gathers the capabilities of the browser, not the screen the browser as a
client runs within. This would however allow you to check if the client
supports javascript, and thus send some javascript to gather the client
screen dimensions.

You can look at it here.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpbrowsercapabilitiesmemberstopic.asp


The javascript approach is very easy, theres a good example here:
http://www.devcity.net/Articles/64/1/screenresolution.aspx

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

Show quoteHide quote
"Bredahl jensen" <bredhal.jen***@yahoo.dk> wrote in message
news:ep7vhMabFHA.2696@TK2MSFTNGP09.phx.gbl...
>
> Most of the the solution i have seen was throught javascript.
>
>
> Many thanks in advance
>
>
> JB
>
>
Are all your drivers up to date? click for free checkup

Author
10 Jun 2005 10:58 AM
Bredahl jensen
Right i know there is no permanent connection between client and web app but
there is at least one a every request..
The Context objects gathers a lot of client side data and i thought there
was some similar object for screen resolution.

Anyway many thanks for you excellents links.

JB
Author
10 Jun 2005 11:35 AM
Hans Kesting
John Timney (ASP.NET MVP) wrote:
> There is no connection between the server and the client other than
> when a request is made - so javascript would be the most appropriate
> way.  There is a server side class called the HttpBrowserCapabilities Class but it only gathers the capabilities of
> the browser, not the screen the browser as a client runs within. This
> would however allow you to check if the client supports javascript,
> and thus send some javascript to gather the client screen dimensions.
>

And those browsercapabilities are based on what is *defined* for a particular
browser-string, NOT what this particular client actually *can* do:

* browser could be capable of javascript, but the user can have switched
   that off -- not detected
* some browsers (Opera) allow user-defined browser-strings -- incorrect detection
* the list of capabilities per browser-string is out-of-date -- newer browsers
  (Firefox) are not detected correctly (with the original browserCaps)


Hans Kesting
Author
10 Jun 2005 12:02 PM
Juan T. Llibre
re:
> * the list of capabilities per browser-string is out-of-date -- newer browsers
>  (Firefox) are not detected correctly (with the original browserCaps)

I strongly recommend that *everybody* update
their BrowserCaps section per the code at this link :

http://slingfive.com/pages/code/browserCaps/browserCaps_spaces.txt

Modifying the site's web.config per the code at that page will send HTML
which Firefox, Mozilla, Konqueror, Opera and Mac's Safari can understand.

That makes for a huge difference in accessibility.



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

Show quoteHide quote
"Hans Kesting" <news.2.hansdk@spamgourmet.com> wrote in message
news:eFv2FCbbFHA.1504@TK2MSFTNGP15.phx.gbl...
> John Timney (ASP.NET MVP) wrote:
>> There is no connection between the server and the client other than
>> when a request is made - so javascript would be the most appropriate
>> way.  There is a server side class called the HttpBrowserCapabilities Class but it only
>> gathers the capabilities of
>> the browser, not the screen the browser as a client runs within. This
>> would however allow you to check if the client supports javascript,
>> and thus send some javascript to gather the client screen dimensions.
>>
>
> And those browsercapabilities are based on what is *defined* for a particular
> browser-string, NOT what this particular client actually *can* do:
>
> * browser could be capable of javascript, but the user can have switched
>   that off -- not detected
> * some browsers (Opera) allow user-defined browser-strings -- incorrect detection
> * the list of capabilities per browser-string is out-of-date -- newer browsers
>  (Firefox) are not detected correctly (with the original browserCaps)
>
>
> Hans Kesting
>
>
Author
10 Jun 2005 10:50 PM
John Timney (ASP.NET MVP)
you are entirely correct Hans

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

Show quoteHide quote
"Hans Kesting" <news.2.hansdk@spamgourmet.com> wrote in message
news:eFv2FCbbFHA.1504@TK2MSFTNGP15.phx.gbl...
> John Timney (ASP.NET MVP) wrote:
>> There is no connection between the server and the client other than
>> when a request is made - so javascript would be the most appropriate
>> way.  There is a server side class called the HttpBrowserCapabilities
>> Class but it only gathers the capabilities of
>> the browser, not the screen the browser as a client runs within. This
>> would however allow you to check if the client supports javascript,
>> and thus send some javascript to gather the client screen dimensions.
>>
>
> And those browsercapabilities are based on what is *defined* for a
> particular
> browser-string, NOT what this particular client actually *can* do:
>
> * browser could be capable of javascript, but the user can have switched
>   that off -- not detected
> * some browsers (Opera) allow user-defined browser-strings -- incorrect
> detection
> * the list of capabilities per browser-string is out-of-date -- newer
> browsers
>  (Firefox) are not detected correctly (with the original browserCaps)
>
>
> Hans Kesting
>
>
Author
10 Jun 2005 8:32 PM
David Jessee
Not without a client script gathering the information first. 

Take a look at the section on HTTP messages on the W3C web site.  It will
give you a great understanding of exactly what's being passed between the
client and server.

check out
ftp://ftp.isi.edu/in-notes/rfc2616.txt
Section 4 - HTTP Message
and
Section 5 - Requests


Show quoteHide quote
"Bredahl jensen" wrote:

>
> Most of the the solution i have seen was throught javascript.
>
>
> Many thanks in advance
>
>
> JB
>
>
>
Author
10 Jun 2005 9:25 PM
darrel
> Most of the the solution i have seen was throught javascript.

That's the only way.

Also note that screen resolution != browser viewport size.

-Darrel

Bookmark and Share