Adding # character to solr search query is converting my solr json to xml. How do i fix?
<p>I am having an issue with special characters in my Solr query... specifically the pound sign (#) when added to the Solr search string... Example, searching for 'C#'. </p>

<p>First I am building my URL dependent upon what the user is searching/faceting on.</p>

<pre><code>private string GetURLFromSearch(string search)
{
    string begin = WebConfigurationManager.AppSettings["SolrURI"] + "select?q=";
    string query = search + "*";
    string fq = "";
    ...
    string end = String.Format(
          "&amp;start=0&amp;rows=" + rowsToDisplay + "&amp;wt=json&amp;indent=true&amp;json.nl=map&amp;defType=edismax&amp;qf=acronym^100+cde_project_name^4+cde_description^2+text&amp;facet=true&amp;facet.field="
           ...
           ...
    );
    return begin + query + /*afterQuery + functionRollup +*/ fq + end;
}
</code></pre>

<p>I pass the URL I am building to: </p>

<pre><code>private string GetJSONFromURL(string url)
{
    using (WebClient wc = new WebClient())
    {
        return wc.DownloadString(url);
    }
}
</code></pre>

<p>But when searching "C#", GetJSONFromURL returns XML instead of JSON. I am not sure why this is. </p>

<p>I have tried changing "C#" -> "C%23"
I have also looked into changing the tokenizer in the schema.. but that is a change I am trying to avoid as I believe it would effect many other aspects of our search. </p>

<p>schema.xml</p>

<pre><code>&lt;fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"&gt;
    &lt;analyzer type="index"&gt;
        &lt;tokenizer class="solr.StandardTokenizerFactory"/&gt;
        &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
    &lt;/analyzer&gt;
    &lt;analyzer type="query"&gt;
        &lt;tokenizer class="solr.StandardTokenizerFactory"/&gt;
        &lt;filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/&gt;
        &lt;filter class="solr.LowerCaseFilterFactory"/&gt;
    &lt;/analyzer&gt;
&lt;/fieldType&gt;
</code></pre>

<p>Any help/direction would be appreciated.</p>

<p>Thanks</p>