Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 15th, 2004, 07:00 AM
rl rl is offline
Registered User
 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Session_Start event not fired

Hi there!

Nobody on the Microsoft newsgroups could solve this problem until now, hope to get some advice here.

The following problem occurs on Win2003 Server using ASP.Net 1.1 with VB.Net:
In my global.asax the Session_start event is not fired.
I think this leads to another problem: httpcontext.current.session is undefined and not available. I can't use session variables or such.

SessionState in web.config is enabled (InProc). I tried to use page directives too (EnableSessionState), with no effect.

When running the same app on a WinXP system, everything's fine. It's really confusing for me.

What's the reason for this problem?!

Thank's Reinhard
 
Old April 15th, 2004, 07:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

On your Win2K3 box can you get anything in ASP.NET to work?

 
Old April 15th, 2004, 09:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Did you check IIS session settings? I know in Win2003 by default certain features were turned off by default, which XP Server the default was on.

In Win 2k, to get there it is right-click default web site, click properties, select home directory tab, click the configuration button, click app options. Check it out, and see what it says.

Brian
 
Old April 15th, 2004, 09:24 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Check out this FAQ: http://imar.spaanjaars.com/QuickDocID.aspx?QUICKDOC=254

It's written for Whidbey, but the same principle applies to .NET 1.0 and 1.1. By default, on a clean 2003 installation, .NET is turned off.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: God Put a Smile Upon your Face by Coldplay (Track 3 from the album: A Rush Of Blood To The Head)
 
Old April 16th, 2004, 03:54 AM
rl rl is offline
Registered User
 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all, thank's for replying!

to stu9820:
ASP.Net is running perfectly, ... until I try to use the session object. My WebApp can be started without errors, but when I try to set session vars like
System.Web.HttpContext.Current.Session("MemberId") = SomeString
I'm getting error [NullReferenceException: Object reference not set to an instance of an object.]

to Imar:
I tried to permit all available options as suggested, the problem stays the same.

to bmains:
I checked it and tried out all options, with no effect.
One thing I don't understand concerning IIS settings is the option "Application pool". This is set to "BusinessActivityServicesPool". Don't know if this has something to do with my problem.

Reinhard


 
Old April 16th, 2004, 04:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Reinhard,

If I were you, I would create a small demo project for testing purposes.
Create a new project in VS.NET, accept all defaults. Make sure that the ApplicationPool is set to DefaultPool (although I can't imagine that would be the cause of the problem).
Add two simple pages, one that sets a session variable, and a second that tries to read it. Don't use the Global.asax yet.
Does it work then?

You could also try setting up a separate StateServer for your Sessions, but AFAIK, it should work with InProc as well.....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Judith by The Cult (Track 11 from the album: Love)

 
Old April 16th, 2004, 04:40 AM
rl rl is offline
Registered User
 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar!

I tried this already before, same problem with each project - session object is undefined.

I also tried to use SQL Server for session state, same problem.

Concerning ApplicationPool option: If I set it to DefaultPool my app can't be run. Error message: "Mutex could not be created"
What is a Mutex??!

Thank's
Reinhard
 
Old April 16th, 2004, 04:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I have no idea. What does Google say?

Can you show some of the code you use to set and read the Session variables? What do you have in your Web.Config file?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Star Guitar by The Chemical Brothers (Track 4 from the album: Come With Us)

 
Old April 16th, 2004, 05:06 AM
rl rl is offline
Registered User
 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is my web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

    <appSettings>
        <add key="ConnectionString" value="server=localhost;Trusted_Connection=true;da tabase=IB" />
    </appSettings>

    <system.web>
        <trust level="Full" originUrl="" />

        <authentication mode="Forms">
            <forms name="IBAuth" loginUrl="login.aspx" protection="All" path="/" />
        </authentication>

        <customErrors mode="RemoteOnly" defaultRedirect="ErrorPage.aspx" />

        <compilation debug="true"/>
        <sessionState mode="InProc" cookieless="false" timeout="20" />
    </system.web>

    <location path="Checkout.aspx">
        <system.web>
            <authorization>
                <deny users="?" />
            </authorization>
        </system.web>
    </location>
    <location path="OrderList.aspx">
        <system.web>
            <authorization>
                <deny users="?" />
            </authorization>
        </system.web>
    </location>
    <location path="OrderDetails.aspx">
        <system.web>
            <authorization>
                <deny users="?" />
            </authorization>
        </system.web>
    </location>
</configuration>


and this is the vb-codebehind:
    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        SetFocus(Me.MemberName)
    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click

                System.Web.HttpContext.Current.Session("MemberId") = "20"
                'I tried this too: System.Web.HttpContext.Current.Session("MemberId") = "20"
                'I tried this too: Session("MemberId") = "20"

    End Sub

    Sub SetFocus(ByVal ctrlControl As Control)
        If Not Page.IsStartupScriptRegistered("SetFocus") Then
            Page.RegisterStartupScript("SetFocus", _
               "<" & "script language=""JavaScript"">" & _
                  "document.forms[0]." & _
                  ctrlControl.ClientID & ".focus();" & _
               "</" & "script>")
        End If
    End Sub


I only found one programmer until now who has the same problem. He didn't get any reply to his question. Maybe he's already jumped out of the 26th floor ;)

Reinhard

 
Old April 16th, 2004, 05:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Very strange. I don't see anything wrong here.
Anyway, try the following test. Save the code to two pages, Test1.aspx and Test2.aspx. You can create them in Notepad and drop them in the root of your web site. There is no need to use Visual Studio as the examples use in-line code only. Make sure you either create a clean Web application, or clear any code from the Global.asax file that may cause problems (and recompile).
Code:
Test1.aspx
<%@ Page Language="VB" ClassName="Test1" %>
<script runat="server">
    Private Sub Page_Load(Sender as Object, E As EventArgs)
        Session("MyTest") = "Hello, it works"
    End Sub
</script>
<html>
<head>
    <title>Test 1</title>
</head>
<body>
  Session variable has been set. 
  Click the link to see if it works: <a href="Test2.aspx">Click Me</a>
</body>
</html>
and the second page:
Code:
Test2.aspx
<%@ Page Language="VB" ClassName="Test2" %>
<script runat="server">
    Private Sub Page_Load(Sender as Object, E As EventArgs)
        If Not Session("MyTest") Is Nothing Then
            Label1.Text = Session("MyTest")    
        Else
            Label1.Text = "Hmmm, it didn't work"
        End If
    End Sub
</script>
<html>
<head>
    <title>Test 2</title>
</head>
<body>
  <asp:Label ID="Label1" Runat="Server" />
</body>
</html>
Open Test1.aspx in your browser and click the link to the second page. Does that work?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Get On Top by Red Hot Chili Peppers (Track 5 from the album: Californication)





Similar Threads
Thread Thread Starter Forum Replies Last Post
What if I need control value before event is fired pauliehaha ASP.NET 3.5 Basics 9 May 22nd, 2008 12:51 PM
SortCommend event is being fired twice anup_daware .NET Framework 2.0 2 August 9th, 2006 12:19 AM
SortCommend event is being fired twice anup_daware .NET Framework 1.x 1 August 4th, 2006 05:32 AM
fired event Sorting which wasn't handled fantef ASP.NET 2.0 Basics 0 July 27th, 2006 10:05 AM
DataGrid SortCommand event not fired in UserContro vskumar ASP.NET 1.x and 2.0 Application Design 2 February 17th, 2005 08:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.