Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Request.ApplicationPath and root websites with ASP.NET???

1 view
Skip to first unread message

Brock

unread,
Mar 11, 2002, 3:32:17 PM3/11/02
to
I'll try to keep this brief.
Can anyone help me to understand why IIS cannot use the
Request.ApplicationPath the same way in a root website as it does in a
virtual directory? My reference is to the latest I Buy Spy portal code, but
is applicable to any code of this type. This also applies to the use of the
tilde "~" in ASP.NET code. The tilde should represent the application path
in ASP.NET code so these should be interchangeable.
If you are in a virtual directory:
http://portal.ragingfrog.com/portal - Request.ApplicationPath = /portal
In the root site:
http://portal.ragingfrog.com - Request.ApplicationPath = /

This in itself causes problems, but can be handled. You'd think IIS would
be able to handle it though. If you look at the site links above and hover
over the tabs on the page you will see this difference in URL generation
using the Request.ApplicationPath. It is the EXACT same code deployed to
both a virtual directory and the root. One works, one does not.
This is the code:
*Extra spaces have been added to prevent HTML rendering in this message*

< a href='< %= Application("AppPath") % >/DesktopDefault.aspx?tabindex< %#
Container.ItemIndex % >=&tabid=< %# Ctype(Container.DataItem,
TabStripDetails).TabId% >' class="OtherTabs">< %# Ctype(Container.DataItem,
TabStripDetails).TabName % ></a>

I realize the ~ only works with the new ASP.NET controls and will not work
in this case.
Any input would be greatly appreciated.

Thanks,
Brock


John Timney (Microsoft MVP)

unread,
Mar 12, 2002, 1:26:16 AM3/12/02
to
I think its telling you the correct information. Relative to root,
http://portal.ragingfrog.com/portal - represents an application path of
/portal
relative to root: http://portal.ragingfrog.com - represents an application
path of /

That said, I cant see exactly what your problem is. You seem to need
something a little more flexible, like the root & the application path
together. You might find the URL object more flexible for your needs.

Try using the Request.URL object, its very flexible in breaking down the
actual request location. Try this:

Request.Url.GetLeftPart(UriPartial.Authority)

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional Windows Forms
ISBN: 1861005547
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Brock" <br...@vrsdata.com> wrote in message
news:uGlhOvTyBHA.2324@tkmsftngp02...

Brock

unread,
Mar 11, 2002, 6:53:54 PM3/11/02
to
Yes, I'll have to look at that. The thing is, that code came straight out
of the I Buy Spy portal site from Microsoft. I'm trying to figure out if
their code doesn't work, or if it's me. I'll give your suggestion a shot.

Thanks for the reply,
Brock

"John Timney (Microsoft MVP)" <xyzti...@btinternet.com> wrote in message
news:ePhuJzUyBHA.2856@tkmsftngp05...

Brock

unread,
Mar 12, 2002, 2:05:35 AM3/12/02
to
John,

The problem is this. When deployed to a virtual directory, I need the
root/virtual dir. When deployed to the root, I need just the root. That is
where the tilde and the ApplicationPath are having problems. Neither one of
them works in BOTH scenarios.

Brock

"John Timney (Microsoft MVP)" <xyzti...@btinternet.com> wrote in message
news:ePhuJzUyBHA.2856@tkmsftngp05...

Brock

unread,
Mar 12, 2002, 3:30:31 AM3/12/02
to
I have a solution. I might be able to clean it up more with a little more
research, but this works for both virtual directories and root sites. The
If statement checks on every request, but the code should only process once.
I put this code in the Application_BeginRequest:

' 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

Then just replace all the script calls for <%= Request.ApplicationPath%>
with <%= Application("AppPath")%>
If you have any other suggextions, let me know.

Brock

"Brock" <br...@vrsdata.com> wrote in message
news:uGlhOvTyBHA.2324@tkmsftngp02...

0 new messages