views:

682

answers:

1

I'm using code in the Application_BeingRequest() handler of my Global.asax to do some very primitive URL Rewriting. That works fine, however I'm having issues fetching the rewritten url in JavaScript.

So using URL Rewriting 'www.mydomain.com/dothis' becomes 'www.mydomain.com/?action=dothis' on the server side. Using ASP.Net and Request.QueryString["action"], I get the expected result of 'dothis'. JavaScript, of course, still sees 'www.mydomain.com/dothis' because that's what is displayed in the browser.

I don't suppose there is a way for JavaScript to see the actual page url, even though it's not displayed in the address bar?

+1  A: 

What happens on the server beyond the http interface is not visible to the UA if you don´t tell it explicitly.

The rewrite is happening on the server before the server forward the request to the appropriate handler.

You can tell the UA this in many ways (ask Tim Toady ^^). Hidden form control, a JavaScript variable to mention a few. This is ofc if your framework/server supports this.

anddoutoi
Thanks. Right now I'm using .NET to just right out the value i need directly into a javascript variable....<script>var action = '<% = Request.QueryString["action"]%>';</script>I was just hoping there was a better way. I may use the hidden form control instead, so I can do in the code behind and not on the aspx page.
WesleyJohnson