Not sure if this is IIS or ASP.NET

  • Thread starter Thread starter Vince
  • Start date Start date
V

Vince

Hi,

When connecting to my application via IIS v 5.1, my asp code is
failing in my application start of the global.asax.cs file

string appName =
HttpContext.Current.Request.Url.AbsolutePath.Split(new char[] { '/' })
[1].ToUpper();


Url is null for some reason and I have no idea why.

Im entering http://localhost/myapplication/logon/logon.aspx

It works when i run the project from visual studio in debug mode...IIS
though it doesnt.

Any ideas?
 
Hi,

When connecting to my application via IIS v 5.1, my asp code is
failing in my application start of the global.asax.cs file

string appName =
HttpContext.Current.Request.Url.AbsolutePath.Split(new char[] { '/' })
[1].ToUpper();

Url is null for some reason and I have no idea why.

Im enteringhttp://localhost/myapplication/logon/logon.aspx

It works when i run the project from visual studio in debug mode...IIS
though it doesnt.

Any ideas?

What method do you use in the global.asax? I think you also should
check Url before using it

if(Request != null && Request.Url != null &&
Request.Url.AbsolutePath.Split(new char[] { '/' }).Length>1)
string appName = ...
 
I think Response, Request, ... objects are not available in application
OnStart method
Theoretically it can be called without browser. When IIS restarts
application (for example if web.config was modified).
Not sure though....
But safe bet is not to count on that... Plus I have not seen a design where
you need Request/Response in Application_OnStart method...

George.
 
Back
Top