Re: URGENT: Application_Start - doesn't fire
From: Gordon Smith (GS_at_NoSpam.net)
Date: 02/28/05
- Next message: Wilco Bauwer: "Re: SQL Parameter question"
- Previous message: hecsan07: "Re: SQL Parameter question"
- In reply to: Alvin Bruney [Microsoft MVP]: "Re: URGENT: Application_Start - doesn't fire"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 28 Feb 2005 10:41:36 -0800
Problem Solved!
When things get really strange it often has to do with security (I should
have known). It turns out my application's dll had no security permissions
for the ASP.NET and NETWORK SERVICE accounts. I just added those and
everything worked as expected. The reason why I couldn't get specific
exception information is because in the process of troubleshooting this I
screwed up Web.config (accedentially got two sets of <configuration> tags in
there - oh the curse of mindless cutting and pasting). So, the whole thing
choked when Web.config could not be parsed. That's why I wasn't getting
EITHER Application_Start to fire NOR my custom exception handler (in the
HTTP Module) that sends the e-mail to fire. Without being able to parse
Web.config, the whole thing was dead before having a chance to come to life
enough to fire the application's OnError event handler.
Thank you so much for your time on this thread.
"Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
news:%23u1GtHbHFHA.3072@TK2MSFTNGP10.phx.gbl...
> BUT ONLY the very first time I accessed the
>> application from a client
> That is expected behavior. The application_start event fires once when
> the application starts. If you request another 10 pages, it won't fire
> because the application is already started. Don't confuse it with session
> start.
>
> Use this link for remote debugging
> http://support.microsoft.com/?scid=kb;EN-US;833977
>
> debug="true"
> simply turns on debugging when compilation of the aspx page occurs.
>
> It's as if the Web site simply ignores ANY
>> changes I make once the exception is encountered for the first time.
> You never said what the exception was. It would help to post the exact
> message.
>
>>
>> I'm pretty confused at this point.
> Me 2.
>
> How can I get the Web server itself to
>> tell me more about the exception?
>
> Add an application_onerror event handler. In this handler, write an email
> to yourself passing in the contents of the error - Server.error or
> context.error. It will indicate what exactly is going wrong when the
> exception handler fires.
>
> Remove the defaultRedirect to the generic error page as well for testing
> purposes.
>
> --
> Regards
> Alvin Bruney
> [Shameless Author Plug]
> The Microsoft Office Web Components Black Book with .NET
> available at www.lulu.com/owc
> --------------------------------------------------
>
>
> "Gordon Smith" <GS@NoSpam.net> wrote in message
> news:uSmA9jVHFHA.3472@TK2MSFTNGP09.phx.gbl...
>> << you will need to attach a debugger to the worker process on the server
>> to find out exactly what is going on>>
>>
>> Okay, how do I do that? I have VS.NET 2003, am accessing the Web server
>> across the Internet, and have full administrative access to the Web
>> Server (which is Windows Server 2003/IIS6, with all current
>> patches/updates).
>>
>> Since last post, I have a number of new observations but no solution. I
>> simply need more information *from the server itself* about what's going
>> on.
>>
>> The Web.config for the app in question includes these:
>> <customErrors mode="RemoteOnly" defaultRedirect="GenericError.htm" />
>> (this is the page I keep getting in the client)
>>
>> In an effort to get more info, I switched from this...
>> <customErrors mode="RemoteOnly" defaultRedirect="GenericError.htm" />
>>
>> to this...
>> <configuration>
>> <system.web>
>> <customErrors mode="Off"/>
>> </system.web>
>> </configuration>
>>
>> But kept getting the error page telling me to change the entry in
>> Web.config to the latter (which I had in fact done). It behaves as if the
>> application did not restart - because it treated the <customErrors mode>
>> setting as if it were still <customErrors mode="RemoteOnly"
>> defaultRedirect="GenericError.htm" />
>>
>> I also switched Web.config from this:
>> <compilation
>> defaultLanguage="c#"
>> debug="false"
>> />
>> to this:
>> <compilation
>> defaultLanguage="c#"
>> debug="true"
>> />
>>
>> But the site behaves is as if the changes were never made (and yes, I
>> saved the changes to Web.config).
>>
>> I had originally created the new Web site via a script -so I manually
>> created a brand new Web site on the server (and modified the host headers
>> in IIS so that the old URL would resolve to the new/test Web site) and
>> copied all of the files into it from the site having the problem this
>> thread is all about. The new site came up without an exception (and I
>> got the e-mail sent from Application_Start) - BUT ONLY the very first
>> time I accessed the application from a client. After the first time, I
>> got the exceptions and related behavior as described in my prevoius
>> postings. It seems that no matter what I do, the application will not
>> restart. I have stopped and restarted the Web Site, it's Application
>> pool, (created a new App pool just for this app), and even rebooted the
>> server - but still no dice. I have commented out all of my
>> application_start logic, Session_start logic - but still no change in
>> behavior. It's as if the Web site simply ignores ANY changes I make once
>> the exception is encountered for the first time.
>>
>> I'm pretty confused at this point. How can I get the Web server itself to
>> tell me more about the exception?
>>
>> Thanks!
>>
>>
>>
>> "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
>> news:%23x0TMwSHFHA.3472@TK2MSFTNGP09.phx.gbl...
>>> in your application start handler, send an email to yourself
>>> using the system.web.mail functionality. run the app and see if you get
>>> an email.
>>>
>>> if you don't get an email, you will need to attach a debugger to the
>>> worker process on the server to find out exactly what is going on.
>>>
>>> --
>>> Regards
>>> Alvin Bruney
>>> [Shameless Author Plug]
>>> The Microsoft Office Web Components Black Book with .NET
>>> available at www.lulu.com/owc
>>> --------------------------------------------------
>>>
>>>
>>> "Gordon Smith" <GS@NoSpam.net> wrote in message
>>> news:OEJ638RHFHA.1096@tk2msftngp13.phx.gbl...
>>>> Thanks Alvin.
>>>>
>>>> A couple of things.
>>>> I have a version installed right now that has *all* of the
>>>> Application_Start and all of the Session_Start logic (just to ensure
>>>> that something wasn't interacting with the new/current Session)
>>>> commented out - thereby eliminating the possibility of logic problems,
>>>> AFAIK.
>>>>
>>>> Since last post I have rebooted the server. Still no dice.
>>>>
>>>> << Nope, asp.net is not responsible for serving htm files by default.>>
>>>> Right... that's why I put an default.html file in. I thought that would
>>>> tell me if there was a problem with the Web site (independent of
>>>> ASP.NET) or if there was something going on with ASP.NET. So, unless
>>>> I'm mistaken, I think I have narrowed it down to "something with
>>>> ASP.NET or with my application logic" and not a problem with the Web
>>>> site, itself or IIS - because the default.html file was served just
>>>> fine, but the simple default.aspx was not.
>>>>
>>>> At this point I'm thinking about killing the site and recreating it
>>>> from scratch... but I hate to do that because even if the problem -
>>>> whatever it was - goes away, I don't have the opportunity to know what
>>>> went wrong.
>>>>
>>>>
>>>> "Alvin Bruney [Microsoft MVP]" <www.lulu.com/owc> wrote in message
>>>> news:OMqIrwRHFHA.3156@TK2MSFTNGP10.phx.gbl...
>>>>> >So that tells me it's something about asp.net.
>>>>> Nope, asp.net is not responsible for serving htm files by default.
>>>>>
>>>>> Your application start is firing correctly because you can request a
>>>>> page. Your logic and steps you have taken does not indicate a problem
>>>>> with your application_start handler. Rather, the problem seems to be
>>>>> with the code that fires inside the application_start handler. Try
>>>>> re-writing with some error handling code first to see what gives.
>>>>>
>>>>>
>>>>> --
>>>>> Regards
>>>>> Alvin Bruney
>>>>> [Shameless Author Plug]
>>>>> The Microsoft Office Web Components Black Book with .NET
>>>>> available at www.lulu.com/owc
>>>>> --------------------------------------------------
>>>>>
>>>>>
>>>>> "Gordon Smith" <GS@NoSpam.net> wrote in message
>>>>> news:%23H76KFRHFHA.3912@TK2MSFTNGP10.phx.gbl...
>>>>>> One more observation:
>>>>>> When I have a simple default.htm - that page gets served just fine on
>>>>>> the first request. When I have a simple default.aspx - it chokes. So
>>>>>> that tells me it's something about asp.net.
>>>>>>
>>>>>> Still needing ideas here... thanks.
>>>>>>
>>>>>>
>>>>>> "Gordon Smith" <GS@NoSpam.net> wrote in message
>>>>>> news:%23mP1XRQHFHA.3612@TK2MSFTNGP09.phx.gbl...
>>>>>>>I have four (4) ASP.NET Web applications/Web sites on a IIS/6 -
>>>>>>>Windows Server 2003 production server. 3 of them work fine. I just
>>>>>>>installed the 4th one and it's Application_Start event is not firing.
>>>>>>>
>>>>>>> I have double-checked everything (and rechecked) and I haven't found
>>>>>>> anything that would explain why the Application is not starting.
>>>>>>>
>>>>>>> Here is what I have done so far to troubleshoot this:
>>>>>>>
>>>>>>> In IIS Manager I have ensured that there is a unique Application
>>>>>>> name in the Home Directory tab of the Properties for the Web site in
>>>>>>> question. I have verified that the home directory path is specified
>>>>>>> correctly. All other properties in IIS have identical values to the
>>>>>>> other sites that do work corectly (or have site-specific values that
>>>>>>> make sense). I have stopped and started the Web site via IIS
>>>>>>> Manager. I have verified correct content in Web.config (which is
>>>>>>> virtually identical to the other site's Web.config files). I have
>>>>>>> saved changes to Web.config in an effort to get the application to
>>>>>>> restart. I have recompiled and reinstalled the dll.
>>>>>>>
>>>>>>> I have verified that this particular Web app is in fact online and
>>>>>>> functioning to some extent. This particular Web application connects
>>>>>>> to a database (per settings in Web.config). I have verified that the
>>>>>>> application is, in fact, connecting to the database because I was
>>>>>>> able to log in (and the credentials are verified against a table in
>>>>>>> the database). Furthermore, the Web site will serve up pages. I put
>>>>>>> in a simple "hello world!" default.aspx which is served correctly. I
>>>>>>> also put in my standard default.aspx which hits the database (and
>>>>>>> verified that it hit the database when the page was requested). I
>>>>>>> will note that whenever *any* page is first requested that I get a
>>>>>>> general HTTP exception - but on the second request the page is
>>>>>>> served as expected. So, this Web site is online and "mostly"
>>>>>>> available. The whole problem is that Application_Start does not
>>>>>>> fire - which is a big problem because that's when I load important
>>>>>>> variables into the Application state.
>>>>>>>
>>>>>>> FWIW: Toward fixing this I created a new application pool via IIS
>>>>>>> Manager and placed the Web application into it (and
>>>>>>> stopped/restarted the Web site)... still no dice.
>>>>>>>
>>>>>>> Any ideas for troubleshooting this? I really need Application_Start
>>>>>>> to fire.
>>>>>>>
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
- Next message: Wilco Bauwer: "Re: SQL Parameter question"
- Previous message: hecsan07: "Re: SQL Parameter question"
- In reply to: Alvin Bruney [Microsoft MVP]: "Re: URGENT: Application_Start - doesn't fire"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|