Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to read a querystring in ASP.NET-MVC when hitting /mysite?q=123
    primarykey
    data
    text
    <p>I have a site that external sites are linking to with a campaign ID</p> <blockquote> <p><a href="http://www.example.com?cid=123" rel="nofollow noreferrer">http://www.example.com?cid=123</a> </p> <p>or (with a slash)</p> <p><a href="http://www.example.com/?cid=123" rel="nofollow noreferrer">http://www.example.com/?cid=123</a></p> </blockquote> <p>In the case where you miss off the slash most browsers will go and add it in for you. So in either case, whichever you enter the URL that my application is hit is the second URL above. The QueryString parameter is always available.</p> <p>I was noticing with ASP.NET MVC routing (maybe even without) that when I'm using a virtual directory I don't get this same behavior.</p> <p>For instance if I have <code>'http://www.example.com/virtualdirectory?cid=123'</code>, this will reach my '<code>default.aspx</code>' page (since it doesn't match any route). BUT when I examine the value of <code>Request.QueryString</code> it is blank. If I go to <code>'http://www.example.com/virtualdirectory?cid=123'</code>, then the <code>QueryString</code> value is present in the <code>Request</code> object.</p> <p>If I put a breakpoint in <code>Default.aspx.cs</code> in a newly created MVC project (RTM version of MVC 1.0 - March 2009) then I won't see any query parameters.</p> <p>i was wondering if there is any way of getting access to these parameters in IIS6 and/or IIS7 if the user accesses a virtual directory by means of a URL like <code>/virtualdirectory?cid=123</code>. </p> <p>There may be no solution - but I'm jsut glad I spotted this before linking any partners into a virtual directory!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload