Note that there are some explanatory texts on larger screens.

plurals
  1. POWebRequest.Create improperly decodes url
    primarykey
    data
    text
    <p>I have a url like this: <code>http://localhost:8080/search.json?q=L%u00e6r</code>, which is the encoded search for Lær. </p> <p>Unfortunately creating a WebRequest from this url using <code>WebRequest.Create(url)</code> produces the following url: <code>http://localhost:8080/search.json?q=L%25u00e6r</code>. </p> <p>Notice that it incorrectly decodes <code>%u00e6</code>, and produces <code>%25u00e6r</code>. Is there a way to either convert this kind of unicode escaped value or get WebRequest.Create to properly handle it?</p> <p>This should most likely be reported as a bug to the .net team. <code>WebRequest.Create()</code> cannot use the query string returned by <code>Request.QueryString.ToString()</code> if the query contains a §, æ, ø or å (or any other non-ascii character). Here is a small mvc action which can be used to test it. Call it with the query <code>Query?q=L%C3A6r</code></p> <pre><code>public ActionResult Query() { var query = Request.QueryString.ToString(); var url = "http://localhost:8080?" + query; var request = WebRequest.Create(url); using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) { return new FileStreamResult(stream, "text/plain"); } } </code></pre> <p><strong>Edit</strong>:</p> <p>Unfortunately @animaonline's solution does not work with urls like <code>http://localhost:8080/search.json?q=Lek+%26+L%u00e6r</code>, which are decoded into <code>http://localhost:8080/search.json?q=Lek &amp; Lær</code>, where <code>WebRequest.Create</code> gets confused about the <code>&amp;</code>, and thinks it separates parameters, instead of being part of the parameter <code>q</code>.</p>
    singulars
    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.
 

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