Tuesday, February 26, 2008

Server Application Unavailable

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

Today morning, I got the same error in my ASP.Net application as above. I am not getting this error for first time. But the interesting thing is, I solved the error in different way before. I think this problem can be occurs for many reasons. Since I face the problem and spent time to solve this issue, I think it is better to share ideas with others. It may be helpful for those who will get this error in future.

According to http://support.microsoft.com/kb/315158 the problem occurs because of Aspnet_wp.exe fails to start. By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named "localmachinename\ASPNET". To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account.

Solution 1:

1. Check that ‘IUSR_machine’ and ‘IWAM_machine’

Solution 2:

1. Stops the IIS and the ASP.NET state services.

2. Deletes and then re-creates the ASPNET account by using a known temporary password.

3. Reregisters ASP.NET. This step creates a new random password for the account and applies default ASP.NET access control settings for the account.

4. Restarts the Microsoft Internet Information Services (IIS) service.

Friday, December 28, 2007

Alter Database Authorization in SqlServer 2005

"Database diagram support object can not be installed because this database does not have a valid owner. To continue, first use the files page of the Database properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support object "

I have resolved the above issue few days ago by alter database authorization. According to MSDN the Alter Authorization syntaxt is

ALTER AUTHORIZATION
ON [ :: ] entity_name
TO { SCHEMA OWNER | principal_name }

::=
{
Object | Type | XML Schema Collection | Fulltext Catalog | Schema
| Assembly | Role | Message Type | Contract | Service
| Remote Service Binding | Route | Symmetric Key | Endpoint
| Certificate | Database
}


my SQL statement was

ALTER AUTHORIZATION ON Database::databasename TO username;

Hope it will help you. Enjoy!

Thursday, December 27, 2007

Read Resource Value Programmatically By C#

There are two types of resource file in .net framework 2.0. They are

1. Global Resource File and
2. Local Resource File

Global resource file can be read by GetGlobalResourceObject method. This method takes two parameter: resource class and the resource key. The class name associates with the .resx file name that contains global resources. Suppose we want the value of "LoginText" from global resource file, named Resource.resx, then our statement will be like below

GetGlobalResourceObject("Resource", "LoginText");

Local resource file which normally stored in App_LocalResources folder, can be read by GetLocalResourceObject method. GetLocalResourceObject takes a resource name as parameter. so we can get a local resource value by the following way

lblMessage.Text = GetLocalResourceObject("msgInvalidLink").ToString();

Enjoy!

Thursday, December 13, 2007

Abnormally LDF File Grow Problem in SQL Server 2005

Recently I had faced a peculiar problem with my database LDF file. My total database MDF file size was 12 MB but the LDF file size was unexpectedly 21 GB!!! As a result I couldn't take the backup of the LDF file to our web server since our web server had only 1 GB free space. I have solved the problem by the following SQL command

BACKUP LOG databaseName WITH TRUNCATE_ONLY
GO
DBCC SHRINKFILE (N'database_log' , 2)

Note: If you get "file in use" error message from the above command, try changing the permission to single user mode.

The above command shrink my database log file to 2 MB. Its awesome and solve my problem within few seconds. Hope it will help. :)

Happy Programming!!!