asp.net - Clean way to truncate QueryString from a relative Uri c# -


given uri like:

/path/page/?param1=value1&param2=value2 

as generated using:

url.action("page","path", new { param1 = "value", param2 = "value2" }) 

what cleanest way strip query string result in /path/page/?

after searching in , more wide google search, best answer found create uri object , use uri.getleftpart(uripartial.path) know , use absolute uris.

problem is, not work relative uris, , both doing

uri uri = new uri(new uri("http://www.fakesite.com"), myrelativeuri) string cleanuri = uri.absolutepath 

and

string cleanuri = myrelativeuri.substring(0, myrelativeuri.indexof('?')) 

look sloppy.

i use string clearnuri = myrelativeuri.split('?')[0];

it's clean you're going get.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -