Super Mario
Super Mario

Reputation: 939

read url with hash symbol by django

I have this function:

def facebook_forward(request):
    return HttpResponse(request.build_absolute_uri()) 

When I get to this page with for example:

http://myapp.com/?a=a

The function returns me the the same url, but when I get to this page with:

http://myapp.com/#?a=a

it returns me:

http://myapp.com/

How can I get the text after the hash symbool?

Upvotes: 1

Views: 895

Answers (1)

Nishant Nawarkhede
Nishant Nawarkhede

Reputation: 8400

You cant. The part after # can not sent to server.

Part after # is called as fragment identifieris and only used by the browser

The Fragment component of the URL is the end of the URL from the hash symbol (#) onward. URL Fragments are never sent to the server in the HTTP request— only JavaScript running in the page can see them. So, when your browser loads the URL above, the server sees only “http://www.facebook.com” in the request, and it’s the responsibility of JavaScript in the returned page to examine the URL to find the extra information in the Fragment.

source: https://blogs.msdn.microsoft.com/ieinternals/2011/05/16/url-fragments-and-redirects/

Upvotes: 4

Related Questions