You can easily retrieve the path to the running ASP.NET application, using Request.PhysicalApplicationPath: If the web application is located in C:\Inetpub\wwwroot\WebApplication1, the string AppPath will contain C:\Inetpub\wwwroot\WebApplication1
How to remove white (blank) space from a string
Using the Replace() method you can easily replace the white space from a string with any character you want, or totally remove it. In the following example the white space from the string is removed: This will result in Anthem containing the string StarSpangledBanner.However you can replace the spaces with any character you want, such […]
What is the difference between Windows Authentication and SQL Authentication?
If you are new to the Microsoft SQL Server environment, you probably encountered the possibility to choose between Windows Authentication and SQL Authentication. SQL Authentication SQL Authentication is the typical authentication used for various database systems, composed of a username and a password. Obviously, an instance of SQL Server can have multiple such user accounts […]
How do I get the visitor’s IP address?
There are two possible ways, either using: or using Furthermore there is information that the below line retrieves the actual IP address and not the Proxy: However this hasn’t been tested yet.
How to get a list of SQL Server databases
There are multiple ways of getting a list of the SQL Server databases, the easiest one is to execute the sp_databases stored procedure, like in the example below: Don’t forget to change the connection string to match your server details (IP, userid and password).
How to pop up the Print dialog from a web page
You can very easily pop up the Print dialog using a JavaScript call to a function. The following code works in all major browsers, including Internet Explorer and Firefox:
How to improve the performance of your for loops
Instead of the typical: Use: Because instead of checking the length of the array each loop and comparing it to i, it stores it in a variable arrLen, which is then compared at each loop with i. This saves a few milliseconds, since checking the array length requires slightly more processing power.
How to have PHP show the errors within the current script
Before the PHP code starts, add the following lines: These two lines set script-wide variables that will allow the errors in your current script to output to screen.
Fatal error C1083: Cannot open include file: ‘iostream.h’: No such file or directory when trying to compile your C / C++ code
This is a common mistake among C programmers who start coding in a new environment with a new compiler such as .NET 1.1 or .NET 2.0. You get the error because the iostream.h file is no longer used with these compilers, instead use the ISO compliant file iostream: #include <iostream>;
How to redirect www requests to non-www URL
If you would like to redirect all the requests to the www version of an URL to the non-www version – for example http://www.geekpedia.com to http://geekpedia.com – you can do that by placing the following mod_rewrite rule in your .htaccess file: RewriteCond %{HTTP_HOST} ^www.geekpedia.com$ [NC]RewriteRule ^(.*)$ http://geekpedia.com/$1 [R=301,L] The redirect code 301 means Moved Permanently […]