This issue only exists under IIS5.1. I have found a way of resolving the issue, but it is not satisfactory. I am just wondering if there are other, slightly less obvious solutions.
The issue is I have an ASP.NET AJAX project integrated into an ASP.NET MVC2 solution.
I have a static function on my .aspx page which is tagged with the WebMethod attribute. I am calling it like so:
window.PageMethods.set_path(window.pageURL);
window.PageMethods.EnableEditMode(function (result) {
if (result) {
$find(window.leftPaneID).expand(1);
$('#' + window.startEditButtonID).hide();
$('#' + window.finishEditButtonID).show();
}
});
Under IIS5.1 this results in a 404 because Global.asax is mapping the route incorrectly.
As such, I added this line: routes.IgnoreRoute("{*allaspx}", new { allaspx = @".*\.aspx(/.*)?" });
This was helpful, but not sufficient. Now, I receive a 405 POST not allowed. I did a little more reading and found that this was because of:
Extension: .* // Executable Path: %windir%\Microsoft.Net\Framework\v4.0.3031\aspnet_isapi.dll
If I remove this line in IIS Application Configuration Mappings my PageMethod stops 405ing. Awesome!
Unfortunately, this completely breaks the MVC-aspect of the web application -- URL rewriting is necessary.
More unfortunately, PageMethods have the same extension as MVC actions. So, I'm not sure what to do.
I know I read around and saw some people using WebServices to do this. We're in the final bit of testing before a release and, after speaking with my boss, he does not want to go this route as we're concerned about the complexity of it and the need to retest more than desired.
As such, I'm looking for other solutions. Is it possible to do something like:
routes.MapRoute(
"Dashboard.aspx/EnableEditMode",
"Dashboard.aspx/EnableEditMode"
);
where I hard-code in the pagemethods expected and handle them explicitly? I know it's ugly, but it would be a simple fix for now.
Thanks for reading
EDIT: The solution is to stop supporting IIS5, obviously. :)