When IIS and ASP.NET Don’t Get Along - 30 Oct 2009

Learn to use aspnet_regiis.exe — a hush-hush .NET utility that solves many ASP.NET installation problems.

Don Kiely

October 30, 2009

4 Min Read
ITPro Today logo

Troubleshooting Tips and Tricks

LANGUAGES:C# | VB .NET

TECHNOLOGIES:IIS | aspnet_regiis.exe

 

When IIS and ASP.NET Don't Get Along

Learn to use aspnet_regiis.exe - a hush-hush .NETutility that solves many ASP.NET installation problems.

 

By Don Kiely

 

Despite how cool ASP.NET is and all the promises Microsofthas made for it, sometimes things just go wrong. You're typing code a mile aminute, creating Web pages that are works of art, and you run it to see howyou're doing. Bam! You get an error message. You go into forensics mode, usingyour years of programming experience and .NET's wonderful diagnostics tools toget to the root of the problem and eradicate it.

 

But nothing works.

 

Although it is probably of scant comfort after six hoursof intense investigative debugging, the problem might not be in your code atall. And it might not even be in Microsoft's code, either. A lot of weirderrors can occur in ASP.NET indicating that it isn't installed correctly, orthat something's out of sync with IIS. Maybe you're using some of thevalidation server controls and the client can't find the script file it needsfor client-side validation. Or, an ASPX page simply isn't loading no matterwhat you do.

 

The problem is that ASP.NET installs a bunch of settingsand files it uses to make the .NET magic work in Web applications. There arefile extension mappings so IIS knows what DLL to use to respond to a clientrequest (for a list, go into the Internet Services Manager and the Propertiespage for a Web site; go to the Home or Virtual Directory tab; selectConfiguration; then select the Mappings tab). The WebUIValidation.js used forclient-side validation must be in the right place in the .NET Framework folderin the Windows system directory and in your various Web site directories. Oryou need to manage multiple versions of the Framework.

 

Things can get out of sync in many ways. You mightaccidentally delete a critical file. You might be exploring some IIS deep magicand playing with mappings and other IIS settings. Maybe IIS wasn't installedbefore .NET, so IIS doesn't have a clue what ASP.NET is. Or any of many othertravesties can occur on an otherwise healthy system.

 

The solution is to uninstall and reinstall the .NETFramework on your development machine or server, right? Well, you mightultimately have to do that, but there's an easier way to fix many commonASP.NET and IIS issues. It's a utility Microsoft doesn't make much noise about,barely mentioning it in the documentation: aspnet_regiis.exe. You'll find it insomething like the C:WINDOWSMicrosoft.NETFramework directorywith the other .NET command-line tools. The easiest way to run it is to openthe VS .NET Command Prompt window, which sets all the paths and environmentalsettings for you.

 

The tool has several options, which you can get by runningeither aspnet_regiis or aspnet_regiis -? at the command prompt. Figure 1 showssome of the most useful options you have available.

 

Option

Description

-i

Installs current version of ASP.NET. Same as running regsvr32.exe .

-u

Uninstalls current version of ASP.NET. Same as running regsvr32.exe -u .

-ua

Uninstalls all versions of ASP.NET.

-lv

Lists all the versions installed, together with status and path.

-lk

Lists all the paths of all IIS keys where ASP.NET is installed, together with the version.

-c

Copies the client-side script files of the current version to the aspnet_client subdirectory of each existing Web site.

Figure 1. Theseare some of the most useful options in the aspnet_regiis tool. The -i and -coptions are probably the most useful for eradicating mysterious errors from thelocal machine because they fix mappings and reinstall script files back intotheir proper places.

 

Another nice feature of the tool is it simplifies managingmultiple versions of the .NET Framework on a machine, running different Websites using different versions. This time, run this command:

 

aspnet_regiis -s W3SVC/1/ROOT/MyWebApp

 

where the -s parameter is the path to the Webapplication's virtual directory. This sets the script mappings for the specificversion of ASP.NET.

 

References

Microsoft Knowledge Base Article 318465: "Cannot DebugASP.NET Web Application" (http://support.microsoft.com/default.aspx?scid=kb;en-us;318465)

 

Microsoft Knowledge Base Article 306005: "Repair IISMapping After You Remove and Reinstall IIS" (http://support.microsoft.com/default.aspx?scid=kb;en-us;306005)

 

Deploying .NET Applications: Lifecycle Guide (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/DALGIssues.asp).See the section titled "Using Aspnet_regiis.exe to Manage Multiple Versions ofthe .NET Framework for Your Web Applications."

 

Don Kiely is senior information architect forInformation Insights, a business and technology consultancy in Fairbanks,Alaska. E-mail him at mailto:[email protected].

 

 

 

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like