Monday, May 9, 2011

How to Debug Classic ASP in VS 2010 and Windows 7

Bookmark and Share
In the past, I have been using Team Remote ASP Debugger tool to debug my legacy ASP applications in Windows XP. However, the debugger tool stopped working after I migrated my computer OS to Windows 7. I called their tech support and they told me that that tool no longer works in Windows 7 – I need to buy their Windows 7 version for an upgrade price of $200. Wow! $200 is a little bit pricy for an ASP debugger. The heck with it! I am sure there is an alternative out there. After a few trials and errors over the weekend, I was able to figure out how to debug ASP in VS2010. Here is what you need to do:


1. Make sure that the following Windows features are installed on your computer correctly. To see what already installed on your computer, go to Control Panel >> Programs >>Turn Windows Feathers on or off
>>Under Internet Information Services, enable IIS Management Console, IIS Management Scripts & Tools, and IIS Management Service.
>>Under World Wide Web Services:
>Application Development Features - enable everything
>Common HTTP Features - enable Default Document and Static Content
>Security - enable Basic Authentication, Request Filtering and Windows Authentication
>>Check OK


In IIS, under “Default Web Site”, add a new app that points to the physical location of your files (see the example below for creating a new app named HPUnify . Note that an Application Pool is created with DefaultAppPool.




2. In IIS Manager Features View, double-click Default Document and ensure the Default.asp is in the list. Backup to the Features View and double-click - ASP icon.
• Enable Parent Paths - set to True
• Expand Debugging Properties
i. Enable Client-side Debugging - set to True
ii. Enable Server-side Debugging - set to True
iii. Send Errors to Browser - set to True




3. Go to Explorer, right-click on the top folder, select Properties >> Security. Make sure that you are granted to the full control of the physical folder.



4. Finally to Visual Studio 2010 - run Visual Studio as an administrator! Then, open your website - File >> Open Web Site >> File System and select the root folder then click open. Now in Solution Explorer, right-click on the site root and select Property Pages. Under Build, select "No Build", then under Start Options >> Server, select "Use custom server" and enter the base URL with the port number for the site you created earlier: http://localhost/hp-unify - click OK.





Now Go back to Visual Studio 2010 and select Debug >> Attach to Process. At the bottom of the dialog, select both "Show Processes..." check boxes - then in the "Available Processes" list, scroll to the bottom and select w3wp.exe and then click "Attach". If you get a warning select YES/Continue.





Now set breakpoints in your code.

Finally launch your App from IIS manager by right-click on the app select Manage Application >> Browse. Your app should start and you should be able to step through your code (see my example below)



Hope this information is helpful!

Bookmark and Share

Sunday, May 8, 2011

How to Implement Context-Sensitive Help in ASP.NET App


Bookmark and Share


Context-sensitive help is usually perceived as being tedious or difficult to implement. However, if you’re writing help for a web application, this little javascript trick makes delivering context-sensitive help easy. Using this method, the developer doesn’t have to manually configure any of the URLs, and you as a tech writer have only a minimal amount of work as well. Each page in the application calls the right help topic for the right page. After seeing how easy it is to deliver context-sensitive help this way, I would never use any other method.

Conceptual Explanation
While easy to implement, it’s conceptually tricky to explain. Just so you don’t miss anything, here’s the concept of how it works. Each page in the application has a help button with the exact same code. When a user clicks the help button, the help button calls a javascript that says something like this:
1. What is the name of the current page?
2. OK, great, now change the extension of this page name to .htm.
3. Call this exact same page from the help folder.
It does not matter what tool you are using for this method, as long as the application is a Web application (rather than a Winform application).

Writer’s Role

Writers must follow these steps to deliver the context-sensitive help:
1. If you’re using a tool like RoboHelp or Flare (or any other tool, for that matter), match the help topic’s file names with the application page names that you’re associating the help topic with. For example, if the application page is called contact.aspx (look in the Web address to see the name), then you would rename your help topic’s file name contact.htm. If the application page is named config.aspx, then rename the help topic’s file name corresponding to this page config.htm.
2. Remove each of your help files from any distinct subfolders. You can’t have some files inside folder A, some files inside folder B, others inside folder C, etc. All the files must be within the same folder.
3. Let the developer know the path and folder of the published files.

Developer’s Role

1. In the following javascript code, change the path in red to match the path of the published help folder, and insert this javascript into the header of each page (between the
tags).

function showHelp(){
//this is the name of the domain or the root url you want for the help link
var pagePrefix = “http:/
/samplewebpath/acmeapplication/webhelp/index.htm#”
//this is the help extension that will replace whatever exists on the current page
var helpExtension = “.htm”
//this gets the current full path to the page
var pageName = window.location.pathname;
//this returns just the page name and its extension
pageName = pageName.substring(pageName.lastIndexOf(‘/’) + 1);
//this identifies just the page extension of the current page
var pageExtension = pageName.substring(pageName.lastIndexOf(‘.’));
//this replaces the current page name extension with the help extension
pageName = pagePrefix + pageName.replace(pageExtension, helpExtension)
// this shows you the link that will be opened
//alert(pageName);
//this is the popup script for the new window
myWindow = window.open(pageName, “tinyWindow”, ‘scrollbars=yes,menubar=no,height=600,width=600,resizable=yes,toolbar=no,location=no,status=no’)
//this assures the window will come to the front of the current page
myWindow.focus()
}

2. In the body of your page, call the help topic like this:



Obviously you need to replace the path in red with the path of your actual help button file.

That’s it. Now when the user clicks the help button, the page with the same file name in your help files will appear.






Bookmark and Share