i have Response.Redirect("http://localhost/project/startPage.aspx") i want that the path that i will write will be relative, how can i get the relative path ?because if i will put my project on a server-i dont know the path... Thanks
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Build the Application Path
If Application("AppPath") = Nothing Then
Dim sAbsUri As String = Request.Url.AbsoluteUri
Dim sRawUrl As String = Request.RawUrl
If Request.ApplicationPath = "/" Then
Application("AppPath") = Left(sAbsUri, Len(sAbsUri) - Len(sRawUrl))
Else
Application("AppPath") = Left(sAbsUri, Len(sAbsUri) - Len(sRawUrl)) & Request.ApplicationPath
End If
End If
End Sub
Throughout your application, you may now use Application("AppPath") to get a reference to the root of your application.
This is easily acheived by using the 'tilde' character ('~'). This char can be used when code is run on server, hence your redirect above should look like this:
Response.Redirect("~/startPage.aspx")
I would think you have a Virtual dir on you local machine named:
hi adce-i tried your solution and its worked rof the response.redirect,but when i tried it insted of: btAccidentReport.Attributes.Add("onclick","openNewWindow('http://localhost/project/docPerAccident.aspx?ID="+ExId+"')") i wrote : btDoc.Attributes.Add("onclick","openNewWindow('~/project/docPerAccident.aspx?ID="+ExId+"')")
and it doesnt work , but when i wrote without the ~ btDoc.Attributes.Add("onclick","openNewWindow('/project/docPerAccident.aspx?ID="+ExId+"')") its work!!how can it be?it will always work?its right way to do it? Thanks a lot
Relative path can be used with the combination of ".." or "." with the web URL the page. Suppose you have following file hierarchy:
default.aspx
security/user.aspx
data/entry.aspx
And you are on the user.aspx and want you user to navigate to the default.aspx (or entry.aspx) file. Then you can use Respose.Redirect
("../default.aspx") Respose.Redirect ("../data/entry.aspx") Thanks
hi wunderkinder, I have tried the above methods but i'm still facing the same problem. I have developed the web application and installed it on my computer. It works absolutely on my machine. My question is when I access this web application from another computer
it works there too but sometime it behaves awkward. For example If I click on "button or link" which redirect to another page, SOMETIMES it redirected to the page and sometime it doesn't instead it shows the blank page with the message "The page cannot be
displayed" Can anyone solve this problem? It’s really URGENT! Thanks
Same here, my version of ASP .. 1.1 refuses to parse the ~ sign. So everything must be hard coded. I need to use the ~ in the HTML part of the page (not code), yet that part does not work.
labni
Member
150 Points
30 Posts
relative URL
Sep 21, 2004 05:04 PM|LINK
wunderkinder
Contributor
4960 Points
985 Posts
Re: relative URL
Sep 21, 2004 07:35 PM|LINK
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) ' Build the Application Path If Application("AppPath") = Nothing Then Dim sAbsUri As String = Request.Url.AbsoluteUri Dim sRawUrl As String = Request.RawUrl If Request.ApplicationPath = "/" Then Application("AppPath") = Left(sAbsUri, Len(sAbsUri) - Len(sRawUrl)) Else Application("AppPath") = Left(sAbsUri, Len(sAbsUri) - Len(sRawUrl)) & Request.ApplicationPath End If End If End SubThroughout your application, you may now use Application("AppPath") to get a reference to the root of your application.MrLivingston.com - Take a look at the Livingston Family Web site.
adec
Star
12495 Points
2491 Posts
Re: relative URL
Sep 21, 2004 10:45 PM|LINK
Response.Redirect("~/startPage.aspx")I would think you have a Virtual dir on you local machine named: When moving your solution to a production server, you will probably use a fully qualified domain name, hence an address like this: By using the tilde as directed, you will get the right resolution at all times.Andre Colbiornsen
labni
Member
150 Points
30 Posts
Re: relative URL
Sep 22, 2004 06:43 AM|LINK
labni
Member
150 Points
30 Posts
Re: relative URL
Sep 22, 2004 06:53 AM|LINK
<script type="text/javascript"> function openNewWindow(url) { newwindow=window.open(url,'name','height=500,width=950,left=10,top=0,scrollbars=yes'); if(window.focus) {newwindow.focus()} } </script>firoz.ansari
Contributor
3515 Points
694 Posts
Re: relative URL
Sep 22, 2004 07:06 AM|LINK
default.aspx security/user.aspx data/entry.aspxAnd you are on the user.aspx and want you user to navigate to the default.aspx (or entry.aspx) file. Then you can use Respose.Redirect ("../default.aspx") Respose.Redirect ("../data/entry.aspx") Thankslabni
Member
150 Points
30 Posts
Re: relative URL
Sep 22, 2004 04:47 PM|LINK
Kash
Member
470 Points
107 Posts
Re: relative URL
Sep 28, 2004 02:01 PM|LINK
Shannara
Member
425 Points
85 Posts
Re: relative URL
Oct 03, 2004 11:44 PM|LINK