2

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. :)

tereško
  • 58,060
  • 25
  • 98
  • 150
Sean Anderson
  • 27,963
  • 30
  • 126
  • 237
  • 2
    IIS5 is over a decade old. You serious? – Matti Virkkunen Nov 23 '11 at 20:05
  • Yeah, tell me about it. We called up our Canadian distributor and they said they have their demo machines all running on XP 32bit still... but we're prepared to tell them to come to the next century. Just making sure we have to tell them that. :) – Sean Anderson Nov 23 '11 at 20:06

2 Answers2

1

EDIT : As mentioned below by Sean, the solution that worked is: stop supporting IIS 5.1 :)

Have you read this post by Scott Hanselman?

Nick Knowlson
  • 7,185
  • 6
  • 47
  • 63
  • In the middle of my post I have a call to IgnoreRoute which will match on that + more. Ignoring the route isn't the issue, I believe. Once the route is ignored, its extension (none) gets matched by .* because .* is trying to match the MVC action extension (none). I think the issue has to be resolved after ignoring the route, but before it gets to IIS as the two requests would look identical at that point. – Sean Anderson Nov 23 '11 at 20:20
  • It's all good. I'm just going to take this as it is and tell my boss we're not supporting IIS5 anymore. – Sean Anderson Nov 23 '11 at 20:29
  • Hey, looks like this guy had a similar problem: http://stackoverflow.com/questions/6670898/iis-7-5-wcf-4-0-405-method-not-allowed-error – Nick Knowlson Nov 23 '11 at 20:30
  • Haha, I was about to delete my answer, and it told me "you cannot delete an accepted answer". – Nick Knowlson Nov 23 '11 at 20:31
1

Have you considered upgrading your distributers to IIS Express? If they are just doing demos then it should work just fine for them, and you'll be back to targeting a single IIS SKU.

Wyatt Barnett
  • 15,573
  • 3
  • 34
  • 53