473,503 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

request.applicationpath

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.





Nov 18 '05 #1
2 3788
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

"martin" <ma***************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.





Nov 18 '05 #2
Hi mark,

Thank you very much for that. It works brilliantly.

a very good tip.

cheers

martin.

"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:O6**************@tk2msftngp13.phx.gbl...
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

"martin" <ma***************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.






Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2377
by: Vadym Stetsyak | last post by:
Hi, All! For example if I have http://server/myvirtualpath/someotherpath/page.asp and virtual path on the IIS is http://server/myvirtualpath How can I retrieve above mentioned asp...
0
2326
by: Jim Corey | last post by:
I've seen this same sort of code (below) on other posts. This works fine for me on my development machine, but not when I move it to my hosted site. When I view the source from my machine, I...
1
3540
by: Ponnurangam | last post by:
Hi, I have completed a website using Request.ApplicatioPath in a lot of places. eg.: (<img src='<%= Request.ApplicationPath %>/Images/logo.gif' />) It works locally, but doesn't work thru...
5
5240
by: Miljana | last post by:
Hi, I have one problem with cookies in ASP.NET application. It seems that I can not retreive cookie from Request.Cookies collection. I put cookie in Response.Cookies collection, and after page...
2
2554
by: ad | last post by:
I want to get the Application path, I use the code: string sDir = Request.ApplicationPath ; It run well in code behind, but if I place the code above in Global.asax like: void...
0
1515
by: Chris | last post by:
Hi, i use a masterpage in my application. When navigating to another site without closing the browser and then coming back to the application, the images and css styles are lost. So i did...
0
1414
by: Chris | last post by:
Hi, When navigating to another site without closing the browser and then coming back to the application, the images and css styles are lost. So i did this for the images: <img...
5
1814
by: Rory Becker | last post by:
I have had code in my Application_Start which is intended to run once at the start of my application's life. It loads connection information and similar from a known location. However I...
2
3596
by: CKKwan | last post by:
Dear All, Using VS2008 on Vista (IIS7). Request.ApplicationPath return something like "http://localhost:50440/" When deploy into Server 2003 (IIS6), found that Request.ApplicationPath is...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.