How do you convert a url to a virtual path in asp.net without manual string parsing? -


I have seen the same questions and answers about virtual and full URL conversions, but how can I change a URL Is the virtual path without manual string parsing?

Example:

I want to convert to "" / "/ / home.aspx"

I realize that the above example is an easy string parsing routine Yes, but I am looking for a suitable solution which will be on the scale of change in the URL format.

You can get it from Uri square:

  new Uri ("http://myserver.com/home.aspx"). If you host in a subdirectory, it may be broken - I do not think that this particular specialization is required to be included in the esolith path  

then only ~

One way to do this in context is to edit

Edit: It can do this:

  VirtualPath Utility. Tap Appeal (New Yuri ("http://myserver.com/home.aspx") AbsolutePath)  

Comments