request.applicationpath

  • Thread starter Thread starter martin
  • Start date Start date
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.
 
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
 
Hi mark,

Thank you very much for that. It works brilliantly.

a very good tip.

cheers

martin.
 
Back
Top