3

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 &#39;/csweb/Dashboard/Dashboard.aspx/EnableEditMode&#39; was not found or does not implement IController.
Community
  • 1
  • 1
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237

1 Answers1

1

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("~") %>
Nick Knowlson
  • 7,185
  • 6
  • 47
  • 63
  • This is an ASP.NET AJAX application integrated into an ASP.NET MVC solution. I believe this means that yes, your first statement applies. I will check this first thing Monday morning and give you applicable credit as well as printing out console logs for those two variables. Thank you for your help and hope you're around on Monday. :) Cheers – Sean Anderson Nov 19 '11 at 03:14
  • Working on it. Might get to it today. I came into work Monday morning and the laptop I was working on said OS not found... then I set up a VM with XP x64 only to find out it came with IIS 6.0 not 5.1. Just this very instant got my environment up and running again. Crossing my fingers. :) – Sean Anderson Nov 22 '11 at 20:54
  • So... I'm not seeing the 'null that I previously mentioned anywhere in my build environment now. Perhaps that was just a weird, one-of fluke. I went ahead and edited into my initial post what I see when I print those variables. – Sean Anderson Nov 22 '11 at 21:23
  • Whoa, how strange. I'm assuming AcceptVerbs didn't change anything, right? Looking at this again, it actually might be a problem with the routing. You did say it is an ASP.NET AJAX application integrated into an ASP.NET MVC application, so I imagine routing might be a bit atypical. What file is `EnableEditMode` in? – Nick Knowlson Nov 23 '11 at 19:28
  • Hey Nick. I am making a lot of progress on this, actually! I have gotten my Dashboard's PageMethod to work under IIS5.1, but it broke the MVC side of our application. If I ignore routes which match .aspx I fix the 404 error, but receive a 405 error. If I remove the .* -> aspnet_isapi.dll URL rewrite then the PageMethod works, but MVC does not work because URL rewriting is disabled. EnableEditMode is in Dashboard.aspx – Sean Anderson Nov 23 '11 at 19:46
  • Glad to hear you are making progress! Sounds like you are on the right track. Just checking, have you read this already? http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx – Nick Knowlson Nov 23 '11 at 20:11