How to get client Screen Resolution Width/Height a

2020-04-12 08:32发布

问题:

I can get client screen resolution using client side script 'javascript',

but I dont want to do that.

I also tried Request.Browser.ScreenPixelsWidth, but it always return fixed width as 680.

Any Idea?

回答1:

Information such as client screen resolution is never sent to the server in the HTTP request so you may forget about it. The only way is to use javascript and then pass this information to the server (AJAX, form post, link, ...). You could also use some proprietary browser plugin like Flash, Silverlight, Java Applet, ActiveX, ...



回答2:

I've just had to do something similar, and what I've done is use Javascript to set a cookie when the user loads the login page, then every subsequent request can retrieve the cookie server side.

The approach is not without it's limitations, but it does provide the information you need for the most part.



标签: asp.net