Code Project

Link Unit

Tuesday, December 22, 2009

Bad Request (Invalid Hostname)

While trying to host a site on IIS /windows 2003 devleoped in ASP, we got the following error.
"Http Error 404 - Bad Request (Invalid Hostname)" .
Located the file C:\WINNT\system32\LogFiles\HTTPERR.log to see if the error could be diagnosed with error description. All the other websites were running fine.

Solution: In Web Site Advanced property Host Header value was specified. Removing the "Host Header Value" resulted in operating site.

refer the image as shown below

Wednesday, December 16, 2009

Windows 2003 /DC : Application Server Unavailable


While we were hosting an web application on IIS ,got this error
Application Server 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.

On inspecting further the event log has captured following
aspnet_wp.exe could not be launched because the username and/or password supplied in the processModel section of the config file are invalid.aspnet_wp.exe could not be started.HRESULT for the failure: 80004005

Explaination:
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.

To work around this problem, use one of the following methods:


  • Create a weak account that has the correct permissions, and then configure the section of the Machine.config file to use that account.
  • Set the userName attribute to SYSTEM in the section of the Machine.config file.
  • Configure the section of the Machine.config file to use an administrator account.

One other special value for userName is System, with the password AutoGenerate, which runs the process as an administrative account and allows all ASP.NET user code running under the process to have full administrative privileges.
For deployment on local development environment one can use 2nd option , for deployment on client side 1st option is the best.

System.InvalidOperationException: The control with ID requires a ScriptManager on the page. The ScriptManager must appear before any controls that

System.InvalidOperationException: The control with ID requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

We faced this error while working on one of our project's page. The error appear to be very silly as Scriptmanager was declared on the page; page worked fine on it's first load. After postback,it was giving the above error. On inspecting the page further it was found the culprit was "Page.Items.Clear()" . It was clearing all objects including Scriptmanager from Page's object list.
Rule of Thumb : donot use "Page.Items.Clear()" when using Ajax