asp.net - Clean way to truncate QueryString from a relative Uri c# -
given uri like:
/path/page/?param1=value1¶m2=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
Post a Comment