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

B

Bredahl jensen

Most of the the solution i have seen was throught javascript.


Many thanks in advance


JB
 
J

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/d...temwebhttpbrowsercapabilitiesmemberstopic.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
 
B

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
 
H

Hans Kesting

John said:
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
 
J

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.
 
G

Guest

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
 
D

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
 
J

John Timney \(ASP.NET MVP\)

you are entirely correct Hans

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top