Monday, 29 October 2012 Application and Request Paths Explained

I want to do something simple. Using the current request, obtain the absolute url of the site root and then add another file path to it. For example, taking the request which might be, I want to obtain and then I want to add on e.g. /otherdir/otherfile.aspx to be used in a password reset email.
Anyway, not really doable out-of-the box but then I realised what I really wanted was a reference for all the path relevant elements of the request object so I could work out which bits I needed to glue together. Well, here it is:

->ApplicationPath = "/MyApp"
->AppRelativeCurrentExecutionFilePath = "~/SubDir/Current.aspx"
->CurrentExecutionFilePath = "/MyApp/SubDir/Current.aspx"
->CurrentExecutionFilePathExtension = ".aspx"
->FilePath= "/MyApp/SubDir/Current.aspx"
->Path= "/MyApp/SubDir/Current.aspx"
->PhysicalApplicationPath= "C:\\inetpub\\wwwroot\\MyApp\\"
->PhysicalPath= "C:\\inetpub\\wwwroot\\MyApp\\SubDir\\Current.aspx"
->RawUrl= "/MyApp/SubDir/Current.aspx"
->->AbsolutePath = "/MyApp/SubDir/Current.aspx"
->->AbsoluteUri = "http://localhost/MyApp/SubDir/Current.aspx"
->->Authority = "localhost"
->->DnsSafeHost = "localhost"
->->Host = "localhost"
->->LocalPath = "/MyApp/SubDir/Current.aspx"
->->OriginalString = "http://localhost:80/MyApp/SubDir/Current.aspx"
->->PathAndQuery = "/MyApp/SubDir/Current.aspx"
->->Port = 80
->->Scheme = "http"
->->->[0] = "/"
->->->[1] = "MyApp/"
->->->[2] = "SubDir/"
->->->[3] = "Current.aspx"
->UserHostAddress= ""
->UserHostName= ""
Post a Comment