0

http://localhost/ReportServer/Reserved.ReportServer?/Report+Project1&rs:Command=ListChildren

I would like get parts of url with report folder (Report Project1). I tried HttpContext.Current.Request.Url.Segments but this return array with this items: "\", "ReportServer", "Reserved.ReportServer"

How I get parts with Report Project1?

bluray
  • 1,875
  • 5
  • 36
  • 68
  • This are query string paramaters ... Try this `HttpContext.Current.Request.QueryString` – Martin E Jan 09 '17 at 12:11
  • Thanks, but in QueryString is array AllKeys which contains 2 items: null and rs:Command, Report Project 1 isnt in this array – bluray Jan 09 '17 at 12:17
  • than you Need to build your url correctly which would be: ...ReportServer?/&Report=Project1&rs=ListChildren or what is rs supposed to be. than Access it via ctx.Request.Params.Get("rs") or ("Report") or via QueryString – Luca Jan 09 '17 at 12:18
  • Or try removing the `/` after your `?`. this could be the problem. – Martin E Jan 09 '17 at 12:24

2 Answers2

2

This is correct solution:

HttpContext.Current.Request.QueryString.Get(0)
bluray
  • 1,875
  • 5
  • 36
  • 68
1

Because the query in this request aren't standard i.e. the first parameter doesn't have a variable name only the folder path, you can't get the URI query param in a reliable way. The following code will provide the functionality you want, but perhaps using a simple String.split() looking for the regex of folder would be more reliable.

Uri temp = new Uri("http://localhost/ReportServer/Reserved.ReportServer?/Report+Project1&rs:Command=ListChildren");
string query = temp.Query;
var folder = HttpUtility.ParseQueryString(query).Get(null);

Where the null value is in the Get method, you should really provide the variable name, in your example putting rs:Command there would return the value of that param.

Dan Gardner
  • 1,069
  • 2
  • 13
  • 29