ASP.NET 3.5中处理程序(ASHX)发生了什么

时间:2009-02-02 23:10:12

标签: .net asp.net handler ashx

为什么ASP.NET 3.5 Web应用程序中的默认“通用处理程序”代码会向类添加属性,但不会向正确的命名空间引用添加属性。这是他们开箱即用的模板:

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;
            }
        }
    }
}

为什么他们在顶部没有一条线:

using System.Web.Services;

这是微软默认模板中的错误吗?我错过了什么吗?

1 个答案:

答案 0 :(得分:4)

编辑:我现在看到了,当你将一个通用处理程序添加到一个web 应用程序时(抱歉,我第一次错过了你的问题)我得到了新的无效模板。我同意其他用户您应该只编辑默认模板。如果您正在使用MVC,则不再需要处理程序。

看起来这是一个已知错误,here's the MS Connect issue for it

如果你想编辑模板,它位于:C:\ Program Files \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ ItemTemplates \ CSharp \ Web \ 1033 \ Handler.zip

相关问题