Active TopicsActive Topics  Display List of Forum MembersMemberlist  CalendarCalendar  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Microsoft Learning
 Kaanosh Forums :I.T. Learning :Microsoft Learning
Message Icon Topic: Get Application Path [C# / ASP.NET] HTTP Path Post Reply Post New Topic
Author Message
kaanosh
Admin Group
Admin Group
Avatar

Joined: 01 Jan 2006
Online Status: Offline
Posts: 254
Quote kaanosh Replybullet Topic: Get Application Path [C# / ASP.NET] HTTP Path
    Posted: 11 May 2007 at 7:16am
public string GetApplicationPath()
  {
   string applicationPath = "";

   if (this.Page.Request.Url != null)
    applicationPath = this.Page.Request.Url.AbsoluteUri.Substring( 
     0, this.Request.Url.AbsoluteUri.ToLower().IndexOf(
      this.Request.ApplicationPath.ToLower(), 
       this.Request.Url.AbsoluteUri.ToLower().IndexOf(
      this.Page.Request.Url.Authority.ToLower()) + 
      this.Page.Request.Url.Authority.Length) + 
     this.Request.ApplicationPath.Length);
  return applicationPath;
  }

Use this in any ASP.NET page to get the application path. For example, if you run this function in http://localhost/pathtest/test.aspx, the function will return http://localhost/pathtest/

Another way to redirect is to use the .NET tilde. For example, to navigate to the home page of your website from any place, you would do Response.Redirect(“~”); or even ~/default.aspx.

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0,172 seconds.