Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top