0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.