Web Q&A

Allowing ASP in IIS 6.0, Sorting XML Elements, SSL and Navigation, and More

Edited by Nancy Michell

Q I'm trying to set an ASP page to be the default for a Microsoft® Internet Information Services (IIS) 6.0 server, but doing this results in a "page can't be displayed" error. When I name the page default.htm, it works fine. Is this a configuration problem?

Q I'm trying to set an ASP page to be the default for a Microsoft® Internet Information Services (IIS) 6.0 server, but doing this results in a "page can't be displayed" error. When I name the page default.htm, it works fine. Is this a configuration problem?

A This is a question that's been popping up quite frequently as IIS 6.0 nears release status, so hopefully this answer will settle it. In IIS 6.0, you have to "allow" ASP pages to be served because they are not allowed by default. To enable them, start Inetmgr, click on WebServiceExtensions | Active Server pages | Allow.

A This is a question that's been popping up quite frequently as IIS 6.0 nears release status, so hopefully this answer will settle it. In IIS 6.0, you have to "allow" ASP pages to be served because they are not allowed by default. To enable them, start Inetmgr, click on WebServiceExtensions | Active Server pages | Allow.

Restart the Web service and the ASP pages will start working. For more information about what IIS 6.0 does by default, see "Security in IIS 6.0: Innovations in Internet Information Services Let You Tightly Guard Secure Data and Server Processes" in the September 2002 issue of MSDN® Magazine.

Q I have an XML document (see Figure 1) that I want to convert so that elements with the same category are collected together (see Figure 2). Is this possible using XSL?

Q I have an XML document (see Figure 1) that I want to convert so that elements with the same category are collected together (see Figure 2). Is this possible using XSL?

categoryName1

pname1 somenodes and subnodes

pname2 somenodes and subnodes

categoryName2

pname3 somenodes and subnodes

pname1 categoryName1 somenodes and subnodes

pname2 categoryName1 somenodes and subnodes

pname3 categoryName2 somenodes and subnodes

A Yes, the key point is to think through the construction, like so: ... The full stylesheet for your sample is shown in Figure 3.

A Yes, the key point is to think through the construction, like so: ... The full stylesheet for your sample is shown in Figure 3.

 

 

Q I'm having a DataGrid problem. My current project uses the Microsoft .NET DataGrid control everywhere. Certain DataGrid columns, such as Linkbutton, generate client-side script to perform a postback to the page. This all works great in a non-secured HTTP site. The problem arises when Secure Sockets Layer (SSL) is turned on for the site. After SSL is enabled, the browser warns the user that they're about to leave a secure Internet connection. This happens even when navigating between two HTTPS pages. Turning off the "Warn if changing between secure and non-secure mode" setting in Microsoft Internet Explorer would not be a solution because I don't control the user's browser settings.

Q I'm having a DataGrid problem. My current project uses the Microsoft .NET DataGrid control everywhere. Certain DataGrid columns, such as Linkbutton, generate client-side script to perform a postback to the page. This all works great in a non-secured HTTP site. The problem arises when Secure Sockets Layer (SSL) is turned on for the site. After SSL is enabled, the browser warns the user that they're about to leave a secure Internet connection. This happens even when navigating between two HTTPS pages. Turning off the "Warn if changing between secure and non-secure mode" setting in Microsoft Internet Explorer would not be a solution because I don't control the user's browser settings.

The problem appears to stem from the generated JavaScript of the DataGrid. The href appears to cause the warning prompt in Internet Explorer (see Generating Client-Side Script for Postback).

A In Internet Explorer (at least since version 4.0), misreporting a move to an unsecured zone happens when accessing an SSL site and then navigating from a linkbutton that's nested by more than one level inside a control tree (it will have one or more colons in its NAME attribute when rendered). The browser code responsible for this check has trouble when more than one colon is passed in an href attribute, so it throws the "you are changing zone" warning. Look for a patch for Internet Explorer 6.0 in the future.

A In Internet Explorer (at least since version 4.0), misreporting a move to an unsecured zone happens when accessing an SSL site and then navigating from a linkbutton that's nested by more than one level inside a control tree (it will have one or more colons in its NAME attribute when rendered). The browser code responsible for this check has trouble when more than one colon is passed in an href attribute, so it throws the "you are changing zone" warning. Look for a patch for Internet Explorer 6.0 in the future.

You can confirm that this is your problem by capturing the rendered source of your problem pages, manually editing the linkbuttons by switching any colon delimiters to underscores in the NAME attributes, then viewing the static version to see if clicking the links is causing the issue.

You can also work around this problem by ensuring that your linkbuttons are not nested within another control.

Q Is it possible to take any working JScript® file that ends with .js, put it into a .wsf file with the correct XML package tags and have it run properly? In other words, my file, File.js WScript.Echo("Hello World"); could be turned into File.wsf:

If I run either one of these from a cmd window, they both work fine. But if I add a for loop into them, they stop working. Why don't my loops work in a .wsf file?

Q Is it possible to take any working JScript® file that ends with .js, put it into a .wsf file with the correct XML package tags and have it run properly? In other words, my file, File.js WScript.Echo("Hello World"); could be turned into File.wsf:

If I run either one of these from a cmd window, they both work fine. But if I add a for loop into them, they stop working. Why don't my loops work in a .wsf file?

A The following statement turns on strict XML parsing: You need to either use entities or a CDATA section to force special characters (such as <) to be processed as part of the script:

A The following statement turns on strict XML parsing: You need to either use entities or a CDATA section to force special characters (such as <) to be processed as part of the script:

Q I want a file to be downloaded to the user's computer when they press a button on a Web page. I got close with the following: When the button is pressed, I see an HTTP GET /system.log come from the client. The server replies with HTTP OK, Content-Type: application/octet-stream. Depending on the operating system and browser, I might get one of three behaviors. I might get a File Save/Open dialog, the log might open directly in NotePad (I believe this happens when you have a file association for .log), or the log might open directly in the browser. I'm OK with the first two behaviors. It's the third behavior I'd like to eliminate. Why does the log open in the browser?

Q I want a file to be downloaded to the user's computer when they press a button on a Web page. I got close with the following: When the button is pressed, I see an HTTP GET /system.log come from the client. The server replies with HTTP OK, Content-Type: application/octet-stream. Depending on the operating system and browser, I might get one of three behaviors. I might get a File Save/Open dialog, the log might open directly in NotePad (I believe this happens when you have a file association for .log), or the log might open directly in the browser. I'm OK with the first two behaviors. It's the third behavior I'd like to eliminate. Why does the log open in the browser?

A The browser is data-sniffing the file, determining that the content type looks like text/plain, and displaying it accordingly. Whenever Internet Explorer runs across an unknown MIME type or sees no MIME type, it tries to equate the file to a well-known format based on its data. In order to force a download, use the content-disposition header: content-disposition: attachment;filename="DontDisplayMe.log"

A The browser is data-sniffing the file, determining that the content type looks like text/plain, and displaying it accordingly. Whenever Internet Explorer runs across an unknown MIME type or sees no MIME type, it tries to equate the file to a well-known format based on its data. In order to force a download, use the content-disposition header: content-disposition: attachment;filename="DontDisplayMe.log"

Content-disposition should be tested to make sure it works well for you. This page explains the whole process and is a good place to start: Appendix A: MIME Type Detection in Internet Explorer.

Q I need to pull out some data (date of birth) from an XML file and do some calculations on it using the current date (to find the person's current age). It also needs to output nothing if no date of birth is present. How can I do this in XSL?

Q I need to pull out some data (date of birth) from an XML file and do some calculations on it using the current date (to find the person's current age). It also needs to output nothing if no date of birth is present. How can I do this in XSL?

A XSLT 1.0 doesn't provide all the power of a programming language. But it has some basic functions for working with string, number, Boolean, and node-set values. There are some Microsoft extension functions, but none of them do calculations on Date fields. That's one reason msxsl:script was introduced as an extension function, which lets you do anything that a scripting language offers. XML, XSL, and VBScript examples are shown in Figure 4.

A XSLT 1.0 doesn't provide all the power of a programming language. But it has some basic functions for working with string, number, Boolean, and node-set values. There are some Microsoft extension functions, but none of them do calculations on Date fields. That's one reason msxsl:script was introduced as an extension function, which lets you do anything that a scripting language offers. XML, XSL, and VBScript examples are shown in Figure 4.

XMLXSLFunction Age(dob) if len(trim(dob)) = 0 then Age = "" else Age = DateDiff("yyyy", CDate(dob), now) end if End Function Age : OutputOutput Age : 25

Got a question? Send questions and comments to WebQA@microsoft.com.

Thanks to the following Microsoft developers for their technical expertise: Jay Allen, Rayner D'Souza, Tom Getzinger, Sean Jackman, Pranav Kandula, Rick Kennedy, Adam Kim, Anton Lapounor, Martin Palmer (Hewlett-Packard), Ullattil Shaji, Mark Wilson-Thomas, Rok Yu.