Click here to Skip to main content
14,927,597 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi ,

I am trying to append query to raw URL , but then url is not working i want to add extra so using & symbol and trying to append .

Response.Redirect(Request.RawUrl + "&signoff=manager");

Response.Redirect(Request.RawUrl + "?amp;signoff=manager");
this is working but this is not not givin me value as there are alredy few querystrings are available on my raw url so i must use &
Kornfeld Eliyahu Peter 16-Jun-15 7:20am
'not working' is a poor definition of a problem!
Do you have any errors?
What the actual value of RawUrl?
Is the result of the concatenation valid at all?

This is how I do it:

 var asdiDataUri = new UriBuilder(_url);

var query = HttpUtility.ParseQueryString(asdiDataUri.Query);

query.Add("user", _user);
query.Add("datatype", _dataType);

asdiDataUri.Query = query.ToString();

WebRequest request = WebRequest.Create(asdiDataUri.ToString());

The UriBuilder takes care of multiple querystring existing or none.

You can get the url part and check to ensure there is no # but I think it would handle that too. I haven't tested that much as of yet
Response.Redirect(Request.RawUrl + "&signoff=manager");
This won't work if your RawUrl does not contain a "?". If it contains, then it will work.

So, what you can do is, first check if RawUrl contains "?" or not. If it contains, then add other string with "&", else add string with "?".

If there are doubts, add a comment.
F-ES Sitecore 16-Jun-15 11:00am
There is also the "#" issue to deal with :) If the url has a # then adding the params to the end will cause problems so that needs to be taken into account.
Correct. :)
Torakami 17-Jun-15 1:45am
Yes totally agree ,

thanks a lot for eveyones reply ..
Most welcome. Please accept so that question will be closed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900