A personal repository of technical notes. - CSC

Server-Side Include "Failed to map the path"

Problem
In a VS2005 web site solution, the following server-side include:
<!-- #include virtual="/MyIncludeFile.inc" -->

throws the following error:
Failed to map the path '/MyIncludeFile.inc'.

Web site must be set up in solution as a "Local IIS" or with a Location of "HTTP" rather than "File System".

See quote from "Using IIS with VS 2005 and the new Web Project system - ScottGu's Blog":
The file-system tab option is great if you are working on a self-contained web project that requires no knowledge of the directory or URL structure of content outside its structure.

However, if you are using multiple nested IIS applications or special IIS virtual directory rules on your web server to coordinate multiple applications, then you should avoid opening up these projects using the file-system web option – and instead open them using the “Local IIS” or “Remote Site” tab options. The reason for this is because these nesting and relationship rules are stored in the IIS metabase, and for your application to properly run you will want/need these IIS bindings and semantics to be handled both at runtime and inside VS 2005.

Solution
See How to Convert "File System" web site to "HTTP" web site in VS2005
http://csc-technicalnotes.blogspot.com/2009/02/how-to-convert-file-system-web-site-to.html

References
Local IIS Web Sites
http://msdn.microsoft.com/en-us/library/ckk1e6z4(VS.80).aspx

Server-Side Include Directive Syntax
http://msdn.microsoft.com/en-us/library/3207d0e3(VS.80).aspx

Using IIS with VS 2005 and the new Web Project system - ScottGu's Blog
http://weblogs.asp.net/scottgu/archive/2005/08/23/423409.aspx

DTE.ActiveDocument.Selection Missing Inellisense in Macro

Problem
Can not access properties of Selection object through intellisense in VS macro using Visual Studio Automation and Extensibility.

Solution
To use the Selection property of a text file such as program source code, it must first be cast to a TextSelection:

VB.NET
Dim selection As TextSelection = CType(DTE.ActiveDocument.Selection, TextSelection)

C#.NET
TextSelection selection = (TextSelection)DTE.ActiveDocument.Selection;

References
Document.Selection Property (EnvDTE)
http://msdn.microsoft.com/en-us/library/envdte.document.selection(VS.80).aspx

vwd.webinfo Adds Itself to Web Site

Problem
File vwd.webinfo containing StartupServices with Service ID of {967B4E0D-AD0C-4609-AB67-0FA40C0206D8} keeps adding itself to ASP.NET 2.0 web site.

This was related to a past reference to Crystal Reports.

If you delete this within Visual Studio 2005, it is regenerated after closing solution.

Solution
1) Close Visual Studio
2) Open Windows Explorer
3) Delete vwd.webinfo

References
vwd.webinfo - bytes
http://bytes.com/groups/net-asp/672420-vwd-webinfo

Windows XP CHM Shows Page Not Found

Problem
Compiled Help Module (CHM) shows "Page Not Found" in WinXP.

Solution
Right-click/Properties/Unblock

References
You cannot open HTML Help files from Internet Explorer after you install security update 896358 or Windows Server 2003 Service Pack 1
http://support.microsoft.com/kb/902225/

Has error -- Unable to add ... to the Web. ... Access is denied.

Problem
While using Visual Studio 2005 Copy Web Site function, received this type of error on some files:
Has error -- Unable to add 'MyFolder/MyFile.aspx' to the Web. Unable to add file 'MyFolder\MyFile.aspx'. Access is denied.

Solution
Found that files had been manually copied by another developer and had "Read Only" attribute set. Removed "Ready Only" and it worked.

DataFormatString Not Working

Problem
GridView BoundField DataFormatString not working.

Solution
Specify HtmlEncode="false".

<asp:boundfield datafield="MyDataColumn" headertext="Col Hdr" DataFormatString="{0:p}" HtmlEncode="false"/>

See Microsoft note:
When the HtmlEncode property is true, the value of the field is HTML encoded to its string representation before the formatting string is applied. For some objects, such as dates, you might want to control how the object is displayed with a formatting string. In those cases, you must set the HtmlEncode property to false.
References
BoundField.DataFormatString Property (System.Web.UI.WebControls)
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring(VS.80).aspx

BoundField.HtmlEncode Property (System.Web.UI.WebControls)
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.htmlencode(VS.80).aspx

HTML PRE Tag

<pre></pre>

Preformatted text: The PRE element leaves white space intact, etc.

References
Paragraphs, Lines, and Phrases
http://www.w3.org/TR/REC-html40/struct/text.html#h-9.3.4

XPath Examples

<a>
<b>
<c att='CAttVal'>CVal</c>
</b>
</a>

"a/b/c" = "cVal"
"a/b/c/@att" = "CAttVal"

<a>
<b>
<c att='CAttVal01'>CVal01</c>
<c att='CAttVal02'>CVal02</c>
<c att='CAttVal03'>CVal03</c>
</b>
</a>

"a/b/c[@att='CAttVal02']" = "CVal02"

References
XPath Reference
http://msdn.microsoft.com/en-us/library/ms256115(VS.80).aspx

XPath Examples
http://msdn.microsoft.com/en-us/library/ms256086(VS.80).aspx