Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top