2

I need to get the screen resolution of your visitors on the site. Is it possible to do this in ASP.NET? I get the screen resolution using the code:

var mn = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
int h = mn.Height;
int w = mn.Width;

But this resolution on the server. I need a resolution of client monitor.

yoozer8
  • 7,361
  • 7
  • 58
  • 93
  • 1
    Why do you need this information? Websites should work at any resolution. – Dai Mar 27 '13 at 19:11
  • possible duplicate of [Find the exact height and width of the viewport in a cross-browser way (no Prototype/jQuery)](http://stackoverflow.com/questions/1766861/find-the-exact-height-and-width-of-the-viewport-in-a-cross-browser-way-no-proto) – Adrian Godong Mar 27 '13 at 19:12
  • You are most likely going to have to do it with client side code like JavaScript, even then you will only get the resolution of their browser window. – dkroy Mar 27 '13 at 19:12
  • CSS media queries have become the accepted method for dealing with display resolution in a web app. See e.g. http://line25.com/tutorials/create-a-responsive-web-design-with-media-queries – Dave Clausen Mar 27 '13 at 19:15
  • I need to get the value in the controller! – Voprosec Voprosec Mar 27 '13 at 19:19

1 Answers1

2

You will have to use javascript to accomplish this.availHeight availWidth

window.screen.availHeight
window.screen.availWidth 

Then you will have to pass this back to your application somehow.

Kyle
  • 3,170
  • 1
  • 17
  • 20