PageMethod 404 仅在 XP/IIS 5.1 下部署的网站上。我应该注意哪些安全设置?

发布于 2024-12-17 02:11:00 字数 2700 浏览 7 评论 0原文

这几天一直在解决这个问题,基本上已经没有线索了。

这是代码:

[WebMethod]
public static bool EnableEditMode()
{
    bool successful = false;

    try
    {
        GlobalSettings globalSettings = StateManager.GetStates<GlobalSettings>();
        globalSettings.EditModeEnabled = true;
        StateManager.SaveGlobalSettings(globalSettings);
        successful = true;
    }
    catch (Exception exception)
    {
        _logger.ErrorFormat("Unable to enable edit mode. Reason: {0}", exception.Message);
    }

    return successful;
}

function EnableEditMode() {
    $.ajax({
        type: "POST",
        url: "Dashboard.aspx/EnableEditMode",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (result) {
            if( result ) {
                $find(window.leftPaneID).expand(1);
                $('#' + window.startEditButtonID).hide();
                $('#' + window.finishEditButtonID).show();
            }
        }
    });
}

这是错误消息:

无法加载资源:服务器响应状态为 404 (未找到) http://localhost/csweb/Dashboard/Dashboard.aspx/EnableEditMode

这是我的内容已尝试:

  • 确保我已通过 Windows 更新进行更新。 来源

  • I从我的 ScriptManager 中删除了“EnablePageMethods = True”,并开始使用 jquery ajax POST 来执行代码。当我执行此操作时,没有任何问题,标头略有变化,但没有修复任何内容。

  • 我尝试使用<%= ResolveUrl("~/Dashboard/Dashboard.aspx") %>,但路径没有改变,我没有注意到效果,所以我删除了代码。 来源

  • 我进入我的 web.config 文件并根据以下内容删除了以下内容来源

    <预><代码><授权>; <拒绝用户=“?”/>
  • 我已确保该文件不是只读的,并授予对该文件和父文件夹的完全控制权限系统上的所有相关用户。 (不是实时系统,所以不用担心......只是玩玩)。

  • 我区分了我的工作开发和 非工作部署——我发现请求没有差异 标头。

  • 我在网站上运行了权限向导,表明我希望拥有公开查看的网站的网站安全设置,并将其应用于所有文件夹以替换当前的安全设置。没有效果。

  • 添加了 .json // application/json MIME 类型,没有效果,但我保留了它,因为它看起来很有用。

此时我正准备进入 IIS 设置的深渊。不过,我对 IIS 5.1 不是很熟悉。所以,我想知道我是否应该开始寻找任何特定的地点?

我找到了原因,但我正在研究如何解决它。我有一个集成到 MVC 解决方案中的 ASP.NET AJAX 应用程序。 MVC 方面的事情是选择 PageMethod 并没有正确处理它,但仅限于 IIS 5.1:

[HttpException]: The controller for path &#39;/csweb/Dashboard/Dashboard.aspx/EnableEditMode&#39; was not found or does not implement IController.

Been trouble-shooting this for a few days now and have basically run dry of leads.

Here's the code:

[WebMethod]
public static bool EnableEditMode()
{
    bool successful = false;

    try
    {
        GlobalSettings globalSettings = StateManager.GetStates<GlobalSettings>();
        globalSettings.EditModeEnabled = true;
        StateManager.SaveGlobalSettings(globalSettings);
        successful = true;
    }
    catch (Exception exception)
    {
        _logger.ErrorFormat("Unable to enable edit mode. Reason: {0}", exception.Message);
    }

    return successful;
}

function EnableEditMode() {
    $.ajax({
        type: "POST",
        url: "Dashboard.aspx/EnableEditMode",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (result) {
            if( result ) {
                $find(window.leftPaneID).expand(1);
                $('#' + window.startEditButtonID).hide();
                $('#' + window.finishEditButtonID).show();
            }
        }
    });
}

Here's the error message:

Failed to load resource: the server responded with a status of 404
(Not Found)
http://localhost/csweb/Dashboard/Dashboard.aspx/EnableEditMode

Here's what I've tried:

  • Ensured that I am update-to-date with Windows Updates. Source

  • I removed 'EnablePageMethods = True' from my ScriptManager and started using a jquery ajax POST to execute the code. Nothing broke when I did this, the headers changed slightly, but nothing was fixed.

  • I tried using <%= ResolveUrl("~/Dashboard/Dashboard.aspx") %>, but the path did not change and I did not notice an effect, so I removed the code. Source

  • I went into my web.config file and removed the following according to Source:

    <authorization>
        <deny users="?"/>
    </authorization>
    
  • I've ensured that the file is not ReadOnly and granted full-control permissions on the file and parent-folders for all relevant users on the system. (Not a live system so no worries.. just playing around).

  • I diff'ed the request headers between my working development and
    non-working deployment -- I saw no differences in the request
    headers.

  • I ran Permission Wizard on the website, indicated I wished to have the website security settings of a publicly-viewed website, and applied to all folders replacing current security settings. No effect.

  • Added .json // application/json MIME type, no effect, but I left it in since it seemed useful.

At this point I am suiting up to trek into the abyss of settings which is IIS. I am not very familiar with IIS 5.1, though. So, I am wondering if there are any specific spots I should start looking?

I found the reason, but I am working on figuring out how to fix it. I have an ASP.NET AJAX application integrated into an MVC solution. The MVC side of things is picking up the PageMethod and not handling it properly, but only under IIS 5.1:

[HttpException]: The controller for path '/csweb/Dashboard/Dashboard.aspx/EnableEditMode' was not found or does not implement IController.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软糯酥胸 2024-12-24 02:11:00

您使用的是 ASP.NET MVC 吗?您可能需要 EnableEditMode() 上的 [AcceptVerbs ("POST")]

另外,您可以尝试打印(或调试和查看)以下结果:

var pageURL = "<%= ResolveUrl("~/Dashboard/Dashboard.aspx") %>
var pageURL2 = "<%= ResolveUrl("~") %>

Are you using ASP.NET MVC? You may need [AcceptVerbs ("POST")] on EnableEditMode().

Also, could you try just printing out (or debugging and viewing) the results of:

var pageURL = "<%= ResolveUrl("~/Dashboard/Dashboard.aspx") %>
var pageURL2 = "<%= ResolveUrl("~") %>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文