inicio mail me! sindicaci;ón

Archive for .NET

NDOC for .NET 2.0 Documentation

If you’re looking for clean MSDN-like documentation tool for .NET, NDOC is way to go. Unfortunately development for the tool stopped in Feb 2005. There are a few commercial products as well, but I really was not impressed after playing with a few trials.

The latest release of NDOC version 1.3.1 is only compatible up to .NET 1.1. Microsoft appears to have a new tool for .NET documentation called Sandcastle but after spending an hour of trying to get it setup, time to move on.

I finally found someone who wrote a version compatible with .NET 2.0, NDOC 2.0 Alpha. Despite being an Alpha version, the tool works great, was very familiar and did the job, all for less then 1MB of download.

Screenshot of the application.

Screenshot of output MSDN Chm Help file.

.NET Custom HTTP Handlers

ASP.NET provides a nice way to avoid it’s full web control lifecycle. Why would you want to do this? Well, I found it most useful for doing AJAX work. For example, I have a javascript function I need to have ansynchronously call ASP.NET and return some data to update a HTML elements. In ASP Classic, PHP, Coldfusion, whatever, this is straightforward, the page gets called and some data is outputed. Using Prototypes Ajax.Request I would write the following,

function getSomeData(parameter1) {
  var url = '/file_path/file_name.php';
  var pars = 'param='+parameter1;
  var myAjax = new Ajax.Request(
     url, {
       method: 'get',
       parameters: pars,
       onComplete: doSomethingWithData
       }
     );
}

With ASP.NET I could do the same with an ASPX page, but the request would go through the web control model, which adds overhead. So writing a custom HTTP Handler is one solution. Now there are a few ways to get this setup, but I will use the way I think is most straight-forward.

The first thing you’ll do is create a new class and place that class in the App_Code folder. Below is an example of a very simple class that returns data that will be consumed by the javascript function above. Within Visual Studio add a new class to your App_Code directory and call it, myhttphandler.cs.

using System;
using System.Web;

namespace MyHttpExtensions
{
  public class HandlerExample : IHttpHandler
  {
    public void ProcessRequest(System.Web.HttpContext context)
    {
      HttpResponse response = context.Response;
      response.write("Data to be use by javascript..data...data..");
    }
    public bool IsReusable
    {
      get {return true;}
    }
  }
}

After you have the class created, within Visual Studio you can create a file called a Generic Handler (file extension .ASHX), which you can put in your application directory. This file looks like,

  < %@ WebHandler Language = "C#"
           Class="MyHttpExtensions.HandlerExample" %>

The class name corresponds to the class you created in your App_Code folder. And there it is, you can now request a ASP.NET page which is very light-weight and avoids normal web control processing.

The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to…

I’ve come across a few times on IIS running on Windows 2003 Server, fortunately the problem is easy to fix. If you are developing ASP .NET 2.0 there’s a chance you are missing the ASP.NET 2.0.XXXXX Web Service Extension.First thing you want to do is open Windows Explorer and navigate to,

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files

Right-click on the folder, click on the permissions tab and give “NETWORK SERVICE” permissions to write to the folder.

Secondly open IIS Manager and click on the Web Service Exension folder. In the right window click “Add a new web service extension…” and enter the following,

Extension Name: ASP.NET v2.0.XXXXX
Required Files: C:\WINDOWS\Microsoft.NET\Framework\v2.0.XXXXX\aspnet_isapi.dll

When completed, IIS should look like below,

Web Services Manager