0

I'm using the old 404-rewrite method on a certain site that is tied to IIS6 *.

So if I enter

http://example.com/non-existent/path

it calls my error page like so

http://example.com/catch.aspx?404;http://example.com/non-existent/path

Great.

Except if I call the page with a fragment, like

http://example.com/non-existent/path#with-fragment

I get the same result as above. I can't find the fragment anywhere:

  • Request.Url
  • Request.Url.OriginalString
  • Request.UrlReferrer
  • Request.RawUrl
  • headers, server variables, etc

This has come up because I want to resolve paths created by AJAX to their server-side versions.

Is there any way for me to retrieve the original path from my handler?

Thanks.

(*) Please don't suggest I change platform. Obviously I would if I could.

harpo
  • 41,820
  • 13
  • 96
  • 131

1 Answers1

2

No, there isn't. The portion of URL after # is never passed to the server per HTTP spec. Has nothing to do with platform.

To work with info after # in javascript you should look at Javascript History plugins/functionality. jQuery has history plugin, asp.net ajax and mvc ajax (partial views et al) have that. Mind you, it's not a very easy thing to implement, you have to get into undo/redo mindset.

It probably won't work if you are trying to handle 404's on the server - server doesn't know that there was something after #. Not sure what you want to do though, 404 handling, or "resolve paths created by AJAX"? What exactly is the goal?

Artemiy
  • 1,969
  • 14
  • 19
  • Wow... you're right. I had never tried to do this on *any* page before. The goal is to handle URL's created by client-side navigation, like example.com/somepage#!some-other-page. Facebook does this for example. If you enter that URL, it will automatically redirect to some-other-page and get rid of the fragment. I didn't realize that was being handled on the client side (so not strictly a redirect). – harpo Nov 05 '10 at 21:04
  • note that #! syntax is special for google - http://code.google.com/web/ajaxcrawling/docs/getting-started.html . This tells google that it can put #!something in the querystring – Artemiy Nov 05 '10 at 22:22