How to know the width and height in pixels of a given image programmatically
You will have to create a Bitmap instance from the image file and then query the Width and Height as follows: VB.NET Dim bm As Bitmap = New Bitmap(Server.MapPath(‘b2346.jpg’)) Response.Write(‘Height :’ + bm.Height.ToString()) Response.Write(‘<br> Width :’ + bm.Width.ToString()) C# Bitmap bm = new Bitmap( Server.MapPath(‘b2346.jpg’)); Response.Write (‘Height :’ + bm.Height.ToString() ); Response.Write (‘<br> Width :’ +bm.Width.ToString() );
Request.ServerVariables(‘LOGON_USER’) always returns empty string in Framework 1.1 . Why? It worked fine in ASP
If Request.ServerVariables(‘LOGON_USER’) is returning an empty string, the problem is probably that your app allows anonymous users. To change this: Open IIS manager right-click on your app name and choose properties Click on directory security tab Edit Authentication and Access Control Uncheck ’Enable anonymous’.
Is there a way to specify CSS only if the browser is IE?
You can examine the Request.UserAgent to check if the browser was IE, define a custom HtmlGenericControl type representing your stylesheet link and set the href property on it depending on if the browser was IE. <LINK rel=stylesheet runat=’server’ id=’lnkStyle’> Where LINK is a HtmlGenericControl. You could then do something like this: VB.NET lnkStyle.Attributes(‘href’) = ‘ie/styles.css’ C# lnkStyle.Attributes[‘href’] = ‘ie/styles.css’ ;
How to create Custom Application Settings in the web.config
In the web.config file add a key-value pair as follows: <configuration> <appSettings> <add key=’PageSize’ value=’10’> </add> </appSettings> </configuration> Then you can access the settings as follows in code: VB.NET Response.Write (ConfigurationSettings.AppSettings(‘PageSize’)) C# Response.Write (ConfigurationSettings.AppSettings[‘PageSize’] );
How to do text encryption and decryption
Here are some interesting articles that talk about encryption and decryption: Encrypting Cookie Data with ASP.NET Using MD5 to Encrypt Passwords in a Database String Encryption With Visual Basic .NET