
392
|
Chapter 12, Extending Visual Studio
#88 Create a File Template
HACK
Similar to the .aspx extension for the Web Form templates, ASP.NET HTTP
Handlers use an .ashx extension. We won’t go into all the differences
between a Web Form and an HTTP Handler in this hack. The salient differ-
ence to note is that the initial text that the HTTP Handler template uses will
be different from the Web Form template. Whereas the .aspx file contains
markup text with angle brackets, the HTTP Handler template is actually all
code; in this case, it’s C# or Visual Basic .NET.
Get Your Template Listed in the Add New Item Dialog
Navigate to the C:\Program Files\Microsoft Visual Studio .NET 2003 folder.
Depending on what language (for example, C# or VB), look for either the
VC# or VB7 folder. Inside the given language folder, look for CSharp-
ProjectItems or VBProjectItems, respectively. Compare the filenames in the
folders to the templates in the Add New Item dialog. This is where Visual
Studio stores templates. It uses a combination of .vsz files and .vsdir files. So
to get our template display, we’ve got to create the appropriate .vsz and .
vsdir files. The entry in the .vsdir file will point to our .vsz file.
VSZ Files. Visual Studio .NET uses .vsz files to launch wizards. These are
simple text files that look like the .ini files of old, but with only one section.
To create a new VSZ file, you can copy one of the