【问题标题】:Site deployed, asp pages work fine, but not my handlers站点已部署,asp 页面工作正常,但不是我的处理程序
【发布时间】:2012-03-01 09:22:54
【问题描述】:

我在 IIS6 上使用 Visual Studio 2010 部署了一个网站。我使用了四种可用方法之一:基本文件复制。这就像命令构建到不同的位置,而不是项目文件夹中通常的调试/发布路径。

无论如何,我发布的网站是响应式的。由于我已授予所有可能的权限,因此我可以浏览内容、获取文件,最重要的是执行 asp/aspx 页面。

我已经声明了以下 http 处理程序,它以调试模式(即http://localhost/blablabla.text)响应 URL/[anytext].text 并此时发回一个空 XML。 部署后同样的事情不起作用。

我的处理程序的代码:

namespace WebApplication3
{
    public class HttpHandler : IHttpHandler
    {
        public void ProcessRequest(System.Web.HttpContext context)
        {
            HttpResponse objResponse = context.Response;
            objResponse.ContentType = "text/plain";
            objResponse.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            objResponse.Write("</xml>");
        }

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

部署在我的 IIS 虚拟目录根目录的 web.config:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation targetFramework="4.0" />
        <httpHandlers>
          <add verb="*" path="*.text" type="WebApplication3.HttpHandler, WebApplication3"/>
        </httpHandlers>
    </system.web>       
</configuration>

如果有帮助,这就是我在 VS2010 解决方案中的 web.config :

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpHandlers>
          <add verb="*" path="*.text" type="WebApplication3.HttpHandler, WebApplication3"/>
        </httpHandlers>
    </system.web>
</configuration>

为什么在发布后不能很好地工作?我想有什么东西不见了。很可能 web.config 从未被读取过?

【问题讨论】:

    标签: asp.net


    【解决方案1】:

    我终于知道这是怎么回事了。我描述的部署过程很好。您需要知道的是,您需要根据添加的处理程序类型来调整 IIS 设置。

    就我而言,我需要在 IIS 中添加扩展名 (.text)。

    http://msdn.microsoft.com/en-us/library/bb515343.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多