.net, Asp.net, IIS, Tips

aspnet_wp.exe could not be launched because the username and/or password supplied in the processModel section of the config file are invalid.

I was running a WinXP box and all of a sudden I started getting a “Server Unavailable” error. I know for a fact that it had to do with the ASPNET account. So here’s what I did that did not help:

1. Give ASPNET account full control over your home directory
2. Delete ASPNET account and ran aspnet_regiis -i
3. Google for the error got me to this link KB315158.

Extract from the article:

RESOLUTION

To work around this problem, use one of the following methods:
•Create a weak account that has the correct permissions, and then configure the <processModel> section of the Machine.config file to use that account.
•Set the userName attribute to SYSTEM in the <processModel> section of the Machine.config file.
•Configure the <processModel> section of the Machine.config file to use an administrator account.

I chose to proceed with option 2. I opened up Machine.Config located in

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config

And modified the following line:

FROM: <processModel autoConfig=”true”/>

TO: <processModel userName=”SYSTEM”/>

I tried accessing the website and still the same error. Well, the one thing that was missing in the article is that the processModel section will only be called when IIS starts. So I did a

Start -> Run -> IISRESET

I tried accessing the website and it started working. I was a little worried about using the SYSTEM account so I went back to the machine.config, reverted the changes I made (set processmodel back to autoconfig) and restarted IIS. Well the site still works.Its crazy… I am not sure as to what happened, but If someone knows why this worked please let me know in the comments!

C#, Microsoft, Technical, Tips, XML

Case insensitive XPath query

I wanted to do a case insensitive xpath lookup in my C# .Net application. There was no direct way that i could find to get the job done, but fortunately the workaround ain’t that difficult. Lets consider the following example:

<xml>
<books>
<book id=”1″ name=”Book1″ type=”fiction” />
<book id=”2″ name=”Book2″ type=”nonfiction” />
<book id=”1″ name=”Book1″ type=”FICTION” />
</books>

To request for all fiction books here is the xpath query:

“books/book[translate(@type, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’, ‘abcdefghijklmnopqrstuvwxyz’) =’fiction'”