views:

315

answers:

1

Hey all!

.NET 3.5 app written in C# here with both jQuery and some ASP.NET AJAX UpdatePanel flavouring. I'm running into an interesting issue. I created a pagination user control that is made up of LinkButtons. The user control fires off an event called CurrentPageChanged whenever someone clicks on a page, previous, first, or next buttons. The page using this pagination control is then responsible for getting the newest set of records based on the pagination control item clicked.

Now, the issue I'm running into is this: If I have a url like this: http://localhost:2798/user/9794/profile, everything works fine. However, if I have a url with the trailing slash (i.e. http://localhost:2798/user/9794/profile/), my UpdatePanel falls on its face with a 405 error.

The exception in question is this:

[Exception] Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 405

Now, I looked at the requests through Chrome's Developer Tools, and I see that it's requesting this url: http://localhost:2798/user/9794/profile/profile. It looks like if there's a trailing slash, it'll append an extra path.

Any ideas how I can get around this?

+1  A: 

It looks like if there's a trailing slash, it'll append an extra path.

Yes, that's how relative URLs work. A browser uses the trailing slash to decide whether the URL refers to a folder (in which case a URL could refer to another file inside that folder), or a file (in which case it would have to look up to the parent folder). So <a href="profile"> inside the trailing-slash-URL will indeed be pointing at .../profile/profile.

Any ideas how I can get around this?

Use absolute URLs (or, better, root-relative URLs like href="/user/9794/profile" everywhere you make a link (either explicitly or via an ASP.NET control). Relative URLs are incompatible with the ‘routed’ style of URL where you may have a variable number of slash-separated bits of data in the URL.

And/or use only canonical URLs, so that the URL for any given resource is always fixed; if you go to the “wrong” version with an extra slash or other redundant stuff in the URL you get a 301 redirect to the “right” version.

bobince
FWIW, I'm using root-relative URLs:/user/userID/profileI'm just trying to handle the trailing slash. None of these links are relative.
LookitsPuck
Can we see the code that happens on CurrentPageChanged? Clearly it has picked up a relative `profile` URL from *somewhere*.
bobince
Could there be a default file configured in IIS that would be profile?(instead of mapping ~/ to ~/default.aspx, it is mapping to ~/profile for example)
Jason Kealey