views:

1324

answers:

1

Why does the default "generic handler" code in an ASP.NET 3.5 web application add attributes to the class but not the correct namespace references. This is the template they give you out-of-the-box:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Handler1
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class People : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

Why don't they have a line at the top:

using System.Web.Services;

Is this a bug in Microsoft's default template? Am I missing something?

+2  A: 

EDIT: I see it now, when you add a Generic Handler to a web application (sorry I missed that in your question the first time) I get the new non-functioning template. I agree with the other user that you should just edit the default template. If you're using MVC, you don't need handlers anymore however.

Looks like it's a known bug, here's the MS Connect issue for it.

If you want to edit the template, it's located here: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\1033\Handler.zip

John Sheehan
I'm moving over to MVC. But I still have a need for an ASHX file in some older apps that have been upgraded to 3.5. I'll just fix my template. Thanks for all your help +1 and answer.
tyndall