request.applicationpath

M

martin

Hi,

I am developing a class to help my asp.net application along.
The class is part of a seperate project although this project is included in
the same solution as my main web application.

I wish to use the function "request.applicationpath" from inside my class.

In solution explorer I have right clicked on the references node and added a
reference to system.web.dll

in the class file I have added the following line

Imports System.Web.HttpRequest

and the main declartion looks like this

Namespace Utility
Public Class WebHelper
Public Function SiteRoot() As String
Dim strServer As String
strServer = Request.ApplicationPath()
Return strServer
End Function
End Class
End Namespace

however visual studio does not like the request.application path. I have
check the docs and unless I am wrong I believe this is a part or

Imports System.Web.HttpRequest which I have imported.

any help is appreciated.

thanks in advance.

martin.
 
M

Mark Fitzpatrick

You have to have it use the current context, in other words, the client
thread that is making the request.

Try HttpContext.Current.Request.ApplicationPath() instead. The same thing
holds true for other context-sensitive items, such as calling the Trace
object, Response, User, etc.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP- FrontPage
 
M

martin

Hi mark,

Thank you very much for that. It works brilliantly.

a very good tip.

cheers

martin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top