UrlQueryString Helper Addition #2

Posted on May 17, 2005 01:19 by LeviRosol

After thinking about this QueryString and Url issue I've been having a bit more, I decided to add a new method to the UrlQueryString[^] object called FileWithQueryString that returns the current file name and querystring prefixed with ~/ for friendly ASP.Net usage. Here's the code:

1/// <summary>  2/// The FileWithQueryString method returns the File name with QueryString, prefixed with ~/ so that .Net will build the relative path  3/// TODO: No folders/sub folders are defined within this method.  4/// </summary>  5/// <param name="PhysicalPath">It works well to pass the Request.PhysicalPath value to this method</param>  6public string FileWithQueryString(string PhysicalPath)  7{  8    return "~/" + Path.GetFileName(PhysicalPath) + this.Get();  9}

The one remaining design flaw is that the folder path is not returned. For my application, that's fine because I'm using a HttpHandlerFactory for my 'pages' and I won't have any sub folder names in my Urls.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

September 6. 2008 17:46