How to remove part of a request from Request.UrlReferrer.AbsoluteUri in C #

I want to remove the Querystring part from my Request.UrlReferrer.AbsoluteUri before redirecting to C #.

For example, if you have

Request.UrlReferrer.AbsoluteUri = "http://localhost:8080/english/index_2011.aspx?logout=true" 

Now I want

 Response.Redirect(Request.UrlReferrer.AbsoluteUri) without QueryString part (?logout=true") 

Please use C #

+6
c # query-string
source share
3 answers

Response.Redirect (Request.UrlReferrer.AbsoluteUri.Substring (0, Request.UrlReferrer.AbsoluteUri.IndexOf ()) '?'); Strike>

EDIT

In fact, you can use:

 Response.Redirect(Request.UrlReferrer.AbsolutePath); 

Check it out on MSDN .

+5
source share

use Request.UrlReferrer.AbsoluteUri.ToString().Split('?')[0]

That should do the trick for you.

+8
source share

A cleaner way is

 Request.UrlReferrer.GetLeftPart(UriPartial.Path) 

Meaning I want everything to be in the way. He must be back

 "http://localhost:8080/english/index_2011.aspx" 
+8
source share

All Articles