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.
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("~") %>