Click here to Skip to main content
14,383,854 members
Rate this:
Please Sign up or sign in to vote.
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");


but
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 &
Posted
Comments
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?
Rate this:
Please Sign up or sign in to vote.

Solution 2

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
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

Quote:
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.
Comments
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100