views:

16

answers:

1

Hello,

I need to get access to the AppFriendlyName of a IIS application in the global.asa Application_Start event (classic ASP)

I am looking for the equivalent of HttpContext.Current.Request.ApplicationPath in the global.asax (ASP.NET)

Is there a way to do that ?

Thanks for your help !

Jerome Wagner

A: 

This is one way to do it..

path = Request.ServerVariables("URL")
position = InStr(2,path,"/",1)
Response.Write Right(Left(path,position-1),position-2) & "<br/>"

although it might not look good on the eyes ;)

UPDATE: Which of course doesn't work in Global.asa, since you can only use the Request object in Session_OnStart and Session_OnEnd. My bad, sorry.

Tchami
The "Request" object does not seem to be available in global.asa Application_Start event which makes it impossible to get the path.
Jerome WAGNER
You're right ofcourse. In that case I don't belive you can do it. Your best bet is to do it in the Session_OnStart event, write the result to an Application variable and then check that on every Session_OnStart event so you only do it once.
Tchami
yes of course. The problem is that i am constrained by a session-less configuration that cannot be changed ; If you add an answer saying that it is not possible by a pure application_start call i'll attribute you the correct answer. thx.
Jerome WAGNER
I updated the answer instead.
Tchami