1

I'm just stumped and am not sure what's going on. I'm also having a hard time researching the issue because I don't exactly know how to ask the right question. This should be an easy question for any of you, but your answer would be so immensely appreciated!

I have an asp.net page with the following element:

<a href="http://www.mysite.com?id=1">Link</a>

Great.

But when I hover over the link on the output page, something happens with ASP and that link will navigate to this url: http://www.mysite.com/?id=1

It adds that extra "/" before the query string. How can I get around this? It is not intuitive to my why this is happening. Is this a web.config issue? It happens even if I just start a new project, create a new page, and put that one element there.

Thanks so much!

And it seems to happen on various browsers.

1
  • What happens if you add the parameter programmatically, just out of curiosity? Commented Apr 13, 2012 at 22:44

2 Answers 2

1

That slash is necessary, the querystring cannot immediately follow the domain. See http://en.wikipedia.org/wiki/URL#Syntax

Your particular URL is omitting the path, but you cannot omit the slash between the domain and path, unless nothing else follows the domain.

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

1 Comment

Thank you very much for your input. I realized this a few hours after I submitted the question with a big ol' facepalm. Hopefully if anyone else runs into the same line of thinking they will find this question. You can mark it as closed. Thanks again for all your help everybode!
1

I'm not sure you would even want to do this.

It's probably happening because that is technically the correct way to form a URL. See RFC-1738

An HTTP URL takes the form:

  http://<host>:<port>/<path>?<searchpart>

where <host> and <port> are as described in Section 3.1. If :<port> is omitted, the port defaults to 80. No user name or password is
allowed. <path> is an HTTP selector, and <searchpart> is a query
string. The is optional, as is the <searchpart> and its
preceding "?". If neither <path> nor <searchpart> is present, the "/" may also be omitted.

Since searchpart is present, the slash is required. It may work without it, but it should probably be there anyways.

Comments

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.