Wednesday, May 18, 2005
by Nik Kalyani
Wednesday, May 18, 2005 9:10:09 AM (Pacific Standard Time, UTC-08:00)

I find social networking technology quite exciting. FOAF (Friend of a Friend) is an interesting specification. It is designed to allow computers to understand the relationships between people using RDF/XML.

There's not much buy-on to this right now because it is squarely in geek territory. I suspect that as soon as Friendster and Orkut figure out how to monetize their networks and publish an API, this might die off. On the other hand, it is conceivable that FOAF becomes the API to expose social networks to outside developers.

Give the Foaf Explorer a whirl.

#    Comments [0] - Trackback    

 Sunday, May 15, 2005
by Nik Kalyani
Sunday, May 15, 2005 3:31:24 PM (Pacific Standard Time, UTC-08:00)

I am working on implementing a WebDAV server for ASP.Net. Yes, I know this capability is built-into IIS6, but unfortunately, it requires that you enable WebDAV on the server, creating a big security hole. Additionally, the built-in implementation is unable to authenticate against a custom membership provider. In any event, my solution is a drop-in component that instantly enables WebDAV capabilities for any ASP.Net app.

One of the challenges when developing any app that relies on headers for passing commands back and forth (as WebDAV does), is that debugging is quite challenging. I explored several tools to sniff HTTP traffic, including a few that were implemented as ISAPI filters. I found all to be cumbersome and requiring sever-side installation. There are many IE add-ons that do this also, but since I am working with WebDAV, there is no browser in the equation. It's purely traffic between Windows and a WebDAV server. 

I had resorted to logging to a file from within my app, until I chanced upon HTTPLook. Wow! This app is awesome. It not only does exactly what I want, but it also has a simple and elegant U.I. (important to me) and has excellent features such as filtered capture etc.

My WebDAV development has become several orders of magnitude easier, thanks to this tool. And as a bonus, the app comes with a CHM help file containing the entire HTTP spec. Too cool.

 

 

#    Comments [2] - Trackback    

ASP.Net | WebDAV

 Saturday, May 07, 2005
by Nik Kalyani
Saturday, May 07, 2005 9:26:05 AM (Pacific Standard Time, UTC-08:00)

Many customers of my File Manager Pro module have asked for the ability to edit documents directly (i.e. click on an edit icon in the file listing in their browser, then edit and save the document). This is easily done for text-based files, and indeed that capability is already implemented. However, for files that require a client-side application, this is not at all simple.

Let's use Microsoft Word as an example. If you click on a Word doc link in your browser, by way of the mime type (or extension as a fall back), the browser is able to determine which application should be launched. It downloads the file to temp storage and then passes on the location to the app after launching it. Any changes made to this document are made to the copy in temp storage and have no bearing on the original file on the web server.

To facilitate the editing of documents on web servers, both server and client must support WebDAV (Web Distributed Authoring and Versioning), a protocol that extends HTTP by defining standards for web document authoring, versioning and publishing. IIS5 and IIS6 natively support WebDAV (although the capability is not on by default.). Windows XP and Mac OS X natively support the ability to map/mount a WebDAV collection as a virtual drive. All Office apps, most Adobe apps, and many other popular applications support the ability to transparently work with documents using the WebDAV protocol. So what's the problem?

For servers on an Intranet, it is easy to enable WebDAV and create an easy to use shared document area. But then again, on an Intranet, why bother when you could have a shared drive. In a hosted scenario, WebDAV is much more difficult to implement due to the security concerns it poses. Currently, IIS does not provide a way to enable/disable WebDAV on a per web basis. So if a hosting provider were to enable WebDAV it would potentially compromise all websites on the server that were not properly secured. For this reason, WebDAV support in hosted scenarios is almost non-existent.

Also non-existent (as far as my Googling indicates), is a "server" API for a custom WebDAV implementation using ASP.Net. There are many client implementations, but if you want to be able to have WebDAV clients access a database-driven document repository, for example, you are on your own. This brings us back to File Manager Pro.

I was quite intrigued by everything WebDAV had to offer and so started doing some testing. I was pleased to find after a few hours of coding that it is possible to write a custom WebDAV server that works on ASP.Net. And so that is precisely what I am going to do. I am going to implement this as a generic API first and then use the API to add document authoring and versioning capabilities to File Manager Pro.

So far, I have tested getting a directory listing and editing a document. I have not implemented saving it, but I know it will work because my IIS logs show the request coming in with the right content.

This is quite exciting because it opens up File Manager Pro, and indeed DNN, to a whole new level of document collaboration. I am quite interested to see how this API may be used in different DNN modules in the future.

 Saturday, April 30, 2005
by Nik Kalyani
Saturday, April 30, 2005 6:37:28 AM (Pacific Standard Time, UTC-08:00)

Order of events in the lifecycle of an ASP.Net page:

    Phase What a control needs to do Method or event to override
    Initialize Initialize settings needed during the lifetime of the incoming Web request. Init event (OnInit method)
    Load view state At the end of this phase, the ViewState property of a control is automatically populated as described in Maintaining State in a Control. A control can override the default implementation of the LoadViewState method to customize state restoration. LoadViewState method
    Process postback data Process incoming form data and update properties accordingly. LoadPostData method (if IPostBackDataHandler is implemented)
    Load Perform actions common to all requests, such as setting up a database query. At this point, server controls in the tree are created and initialized, the state is restored, and form controls reflect client-side data. Load event

    (OnLoad method)

    Send postback change notifications Raise change events in response to state changes between the current and previous postbacks. RaisePostDataChangedEvent method (if IPostBackDataHandler is implemented)
    Handle postback events Handle the client-side event that caused the postback and raise appropriate events on the server. RaisePostBackEvent method(if IPostBackEventHandler is implemented)
    Prerender Perform any updates before the output is rendered. Any changes made to the state of the control in the prerender phase can be saved, while changes made in the rendering phase are lost. PreRender event
    (OnPreRender method)
    Save state The ViewState property of a control is automatically persisted to a string object after this stage. This string object is sent to the client and back as a hidden variable. For improving efficiency, a control can override the SaveViewState method to modify the ViewState property. SaveViewState method
    Render Generate output to be rendered to the client. Render method
    Dispose Perform any final cleanup before the control is torn down. References to expensive resources such as database connections must be released in this phase. Dispose method
    Unload Perform any final cleanup before the control is torn down. Control authors generally perform cleanup in Dispose and do not handle this event. UnLoad event (On UnLoad method)
  1. Note   To override an EventName event, override the OnEventName method (and call base. OnEventName).
  2.  Monday, April 25, 2005
    by Nik Kalyani
    Monday, April 25, 2005 12:43:46 AM (Pacific Standard Time, UTC-08:00)

    Dharmesh Shah asks:

    I’m exploring the use of third-party controls (like Infragistics, ComponentArt, etc.) within my custom modules. My first round of experimentation with Infragistics seems to indicate a problem because of some of the Javascript and other stuff the control tries to insert. Do you have any tips or experience in using these types of controls inside a DNN module?

    Nik’s response:

    This is an issue that is going to plague DNN developers for some time to come. To understand why, let’s examine how components use Javascript.

    Generally speaking, a third-party component will inject JS into your page in one of two ways: (1) by having a <script src=”…”> tag that links to a .js file, or (2) by injecting the script in-line using a <script> tag without the “src” attribute. The former is more efficient because it can benefit from browser caching. It is used for generic code and not for instance-specific initialization etc. The latter is necessary because it allows server-side code to create script on-the-fly. For example, in order to render the portal menu, the data for the menus is rendered on-the-fly.

    Most components are written for ASP.Net applications. Your average ASP.Net application makes use of usercontrols for “shared code” to avoid repeatedly coding things such as headers, footers, feedback forms etc. Embedding a third-party component into these usercontrols is not a problem because it is rare that the same usercontrol is used multiple times on a page. In the case of DNN, usercontrols manifest themselves as “modules” and as any DNN user knows, a module may appear any number of times on a page. This is where the problem begins.

    Forward-thinking component developers have envisioned this scenario and taken measures necessary to ensure the uniqueness of dynamically injected variables and objects in code. If a component developer has not done this, it’s game over when you have multiple instances of the component on the same page since the initialization code will reference only the last instance (if it even works). For example, let’s say we have an image with an ID of “MyImage” and there is a variable tracking the position of this image. The (unoptimized) code injected might look something like this:

    var imgX = document.getElementById(“MyImage”).left;
    var imgY = document.getElementById(“MyImage”).top;

    If this code appears in a DNN module that is instantiated four times on a page, imgX and imgY will be set to the last occurrence of the code. Any further U.I. manipulation by JS will throw errors or produce generally erratic behavior.

    This is the first thing to look for in a third-party component that uses client-side JS. Does it have the ability to be instantiated multiple times on the same page. The test scenario for this is easy. Download the trial version and modify one of the samples so two instances of the component are on the same page (do give them different ID’s). Does it work? If it seems to be working, double-check the page source. Look for Javascript variables and ensure that variables have a unique prefix or suffix. In most cases this will be driven by the ClientID property of the usercontrol as this is the Microsoft-recommended property to use for client-side identiciation of server-side controls.

    I wish I could say that there was an easy workaround if the component does not readily allow multi-instance capability. There just isn’t. Your best bet is to contact the developer and make them aware of this problem. They may have a workaround or might make the change for you.

    Another problem area is with initialization. A number of components will attach a handler to the body.onLoad() cleint-side event of a page to perform initialization. The problem occurs when the component is not well-behaved and or just plain dumb. In this case, it will either over-write an existing handler defined by some other component or even DNN itself, or just append multiple, duplicate handlers for multiple instances of a module. Again, this is something to verify through the page source.

    The ID’s issued to dynamically generated U.I. objects is another problem area. Like variables and code objects, it is imperative that these U.I. objects be given unique ID’s otherwise when code tries to manipulate the object, it will fail.

    The final and most perplexing problem is one of cross-compatibility. A component might do everything right, but if it sets a particular U.I. property to a certain value, and another module on the page emits script that also manipulates the same U.I. property, the result is disastrous. In this case, if changing code is not an option, the only solution is to not have the modules on the same page.

    I hope this information will be helpful in figuring out which components are suitable for DNN and which ones aren’t.

    RSS feed
    Search and Links
    Bling

    View Nik Kalyani's profile on LinkedIn

    Contact me: nik*kalyani.com (replace "*")

    TechBubble
    www.flickr.com
    This is a Flickr badge showing public photos from techbubble. Make your own badge here.
    Statistics
    Total Posts: 214
    This Year: 32
    This Month: 0
    This Week: 0
    Comments: 238
    About the author/Disclaimer

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008
    Nik Kalyani
    Sign In
    All Content © 2008, Nik Kalyani