Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 22, 2007 05:02 AM by jmun
Jul 27, 2007 01:47 AM|LINK
When I run my application locally the path looks like this:
This causes a problem with my links because on my hosting server it doesnt have the myapp directory
Is there any way to configure visual studio express edition to not use the app name like this?
Jul 27, 2007 01:49 AM|LINK
it shouldnt' matter... you should never have it hard-coded in your site.
Where does this cause you an issue?
Jul 27, 2007 02:02 AM|LINK
i hard code links in my master page because i have pages that use the master page inside subdirectories
so in my master page i build my links like this:
Dim base As String = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ApplicationPath & "/"
so im trying to get rid of the Request.ApplicationPath & "/" so that it works the same on my local on remote server
Jul 27, 2007 12:36 PM|LINK
I use this simple function in my app anytime I need to reference the base path. I stick it into my base control/page/etc. This will even take into account for varying ports like you get with VWDE
Public Shared ReadOnly Property UrlBase() As String
Dim _return As String = ""
If HttpContext.Current.Request.Url.Port = 80 Then
_return = "http://" & HttpContext.Current.Request.Url.Host & HttpContext.Current.Request.ApplicationPath
_return = "http://" & HttpContext.Current.Request.Url.Host & ":" & HttpContext.Current.Request.Url.Port & HttpContext.Current.Request.ApplicationPath
If _return.EndsWith("/") Then
_return = _return.Substring(0, _return.Length - 1)
Aug 22, 2007 01:31 AM|LINK
I'm facing a similar problem
On the local machine my application path has the extra /myapp path which does not exist on the server where hosted.
This causes all my links to fail. For example:
This works fine on the server but fails when I run it locally.
When I hard code /myapp/ or remove the initial root '/' in the path it works fine locally but fails on the server. For example
How do I change the app path on the local machine to not have myapp as the root folder.
It seems like a silly issue but has eaten up a lot of my time. I would much appreciate a resolution.
Aug 22, 2007 05:02 AM|LINK
You can use the code that Curt provided or what I did was I created a variable for the base path in my web.config. So in my local config i have it set to
http://localhost/appname/, and on the remote server i have it set to the domain (ie
http://www.yourdomain.com/). So everywhere you need to create an absolute path just prepend that variable.
hope this helps