【问题标题】:Custom handler working on Asp.NET Development server but not on IIS 5.1?自定义处理程序在 Asp.NET 开发服务器上工作但不在 IIS 5.1 上?
【发布时间】:2010-10-18 07:02:43
【问题描述】:

大家好,我遇到了一个愚蠢的问题。

我的自定义处理程序在 Asp.NET 开发服务器上 100% 工作,但是当我将站点发布到 IIS 5.1 时,每当我尝试运行 Comment/Find(通过 AJAX 调用查找用户)时(我知道我的命名处理程序 sux!!! :)

我收到此错误:

页面无法显示 您要查找的页面无法显示,因为页面地址不正确。

请尝试以下方法:

* If you typed the page address in the Address bar, check that it is entered correctly.
* Open the home page and then look for links to the information you want.

HTTP 405 - 资源不允许 互联网信息服务

技术信息(供支持人员使用)

* More information:
  Microsoft Support

我的 AJAX 调用代码是:

 function findUser(skip, take) {
   
        http.open("post", 'Comment/FindUser', true);
        //make a connection to the server ... specifying that you intend to make a GET request
        //to the server. Specifiy the page name and the URL parameters to send
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.setRequestHeader('Criteria', document.getElementById('SearchCriteria').value);
        http.setRequestHeader("Skip", skip);
        http.setRequestHeader("Take", take);
        http.setRequestHeader("Connection", "close");

        //display loading gif
        document.getElementById('ctl00_ContentPlaceHolder1_DivUsers').innerHTML = 'Loading, Please Wait...<br /><img src="Images/loading.gif" /><br /><br />';

        //assign a handler for the response
        http.onreadystatechange = function() { findUserAction(); };

        //actually send the request to the server
        http.send(null);
  
}

谁能帮帮我??

【问题讨论】:

  • 这是停止在开发中使用 cassini 的充分理由和机会
  • 真的吗?所以你应该使用IIS?不是 asp.net 开发服务器。

标签: c# ajax httphandler iis-5


【解决方案1】:

确保您已允许 IIS 服务器上的扩展。开发服务器会自动为您执行此操作。

如果您打开网站的属性,然后转到主目录选项卡并单击配置按钮。

在那里尝试添加您用于处理程序指向的扩展名。将可执行文件设置为 aspnet_isapi.dll(查看标准的 .aspx 扩展名以找到它在您计算机上的位置)并取消选中“检查文件是否存在”。

我已经为此烦恼了几次,这解决了问题

科林·G

【讨论】:

  • 嘿科林,非常感谢您的意见!!!但是,取消选中“检查该文件是否存在”后,我仍然遇到同样的错误。也许这与我无法在 IIS 中运行 CommentHandler.ashx 文件这一事实有关,它给出了无法为 CommentHandler.ashx 解析 XML 的错误?
  • @The_Butcher 您返回什么类型的数据,例如。 json、html、xml?听起来数据比服务有问题。如果您有任何代码,我可以看看将其发送到 gmail.com 上的 pythonandchips
  • 谢谢你!但我解决了这个问题,看看它很傻。仍然认为它有点黑客攻击!
【解决方案2】:

在 IIS 上,并非所有调用都将由 asp.net 处理程序(与开发服务器 cassini 不同)处理,除非调用以 .aspx、.ashx 等结尾。.NET isapi dll 不会处理调用。

线索在

HTTP 405 - 资源不允许 Internet 信息服务

如果文件系统中没有对应的 .ashx 文件,您还需要在 web.config 中映射处理程序。

【讨论】:

    【解决方案3】:

    问题是当我在开发者上调用处理程序时。服务器我称它为like this

    http.open("post", 'Comment/Rate', true);

    因为在我的 web.config 中,我指示它捕获所有“Comment/”网址并调用 CommentHandler.ashx 来处理它。

     <add verb="*" path="Comment/*" type="CoffeeMashup2.CommentHandler"/>
    

    但是由于某些原因在 IIS 中它不起作用,所以我将上面的调用更改为

    http.open("post", 'CommentHandler.ashx/Rate', true);
    

    它的工作 100%

    非常感谢您的帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      相关资源
      最近更新 更多