Wednesday, October 14, 2009

Configuring IIS - A name was started with an invalid character. Error processing resource.

If you are getting this error: "A name was started with an invalid character. Error processing resource" when you try to access your ASP.NET page after a fresh IIS installation,

Then, try to configure IIS by doing this this:

Go to RUN and type this:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i

In some cases this also helps: In the IIS properties (by right clicking "Properties" of "Web Sites" under "IIS" in services), under the ASP.NET tab, the version of ASP.NET is not selected. Select one for your ASP.Net version.

Wednesday, June 24, 2009

Environment variables in C#

C# syntax:
To get the logged-in username:
string username = System.Environment.GetEnvironmentVariable("USERNAME");

To get the name of the client machine:
string machinename = Environment.MachineName;

Friday, May 1, 2009

C# - Difference between Convert and Parse

Convert.ToInt32(string) and Int32.Parse(string) yield identical results except when the string is actually a null. In this case, Int32.Parse(null) throws an ArgumentNullException; but, Convert.ToInt32(null) returns a zero.

Wednesday, April 15, 2009

Response.Redirect exception in .NET 2.0

In .NET 2.0, using Response.Redirect gives an exception,
"Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack."

To solve the problem, use:
Response.Redirect ("Success.aspx", false)

or to end the response, write,
Response.Redirect ("Success.aspx", true)

Wednesday, March 25, 2009

DOS - Tips for DATE and WINZIP

1. For printing DATE in DOS, we use DATE. The format in which the DATE is displayed varies from profile to profile. If you want to change the format of the date, then go to Control Panel>Regional and Language Options. Go to Regional Options tab and click on the Customize button. Go to the Date tab and change the way you want your date to be displayed. You can also change the Date format using the Date separator in the same tab.
Now go to the command prompt and type DATE to get the date display in the format you desire. This is particularly useful when you want to create a file with DATE in its name. If you have '\' in your date, there would be an error.

2. To winzip a file using DOS, locate your Zip exe. Generally, it is in 'Program Files'. Use the following syntax to zip all the .txt files in the folder F:\test. In this example below, we desire a zip file with the name beginning with Ru appended with today's date. So, the name of the zip file created on 03-19-2009 should be:
RuThu 03-19-2009.zip.
Syntax:
"C:\Program Files\WinZip\WZZIP" "F:\test\RU%DATE%.ZIP" F:\test\*.txt

About Us