Skip to content

WebForm hosted in AspNetPanel accessing wisej Session #461

Closed

Description

@itg-assistant

Alex Prinias asked 2016-12-03 02:11:28 UTC

Hi,

I'm trying the AspNetPanel to host a webform. According to the Docs,  "The code in the hosted ASP.NET/MVC page can access any component in the current Wisej application session simply by using the Wisej.Web.Application class."  However, although I set a Wisej.Web.Application.Session.MyVariable in the form containing the AspNetPanel, when I try to access it from within the hosted webform, I find out that Wisej.Web.Application.Session is null.

Is there some misunderstanding?

Best,
Alex

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2016-12-04 22:31:59 UTC

    Hi Alex,

    here is a basic sample for that kind of integration that should also give you an understanding for your problem.

    http://wisej.s3.amazonaws.com/support/attachments/Wisej.AspNetFormIntegration.zip

    Is the ASP page perhaps in a different site of the same server ?

    Hope that helps.

    Best regards
    Frank

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-12-04 23:23:28 UTC

    Dear Frank,

    Thanks for your answer.

    However, this is exactly what I'm doing. In fact, when I run the application you sent, I see the same Null reference exception I saw in my code. Wisej.Web.Application.OpenForms is null, exactly as Wisej.Web.Application.Session was null, in what I had tried.

    Best,
    Alex

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-12-05 21:34:37 UTC

    Hi Alex,

    We tried in many ways but always get a valid session. The Wisej session is restored in Wisej.Core.HttpModule (configured in Web.config) when processing HttpApplication.BeginRequest for pages ending in aspx or cshtml. But in some cases the thread firing BeginRequest is different from the thread executing the Asp.Net page.

    You can also restore the Wisej session using Application.RestoreSession(context). You can place that in Page.Loado or Page.Init, or anywhere before using the Wisej session.

    Try this and let me know:

    protected override void OnLoad(EventArgs e)
    {
    Wisej.Web.Application.RestoreSession(this.Context);
    }
    

    Best,
    Luca

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-12-05 22:10:08 UTC

    Hi guys,

    Luca I had been using the Wisej.Web.dll you had sent me to fix the CheckedList (it has a version 1.3.14.1). I thought it might have been this and changed back to the official 1.3.14, and also put your Session restore in OnLoad. And then I saw Frank's example working. But it proved to be pure luck... on a second attempt I got the null reference exception again.

    On top of that, now I ran the example a few times in a row, I saw that some times the browser opens with the window showing the textbox (in the window) and the button in the Aspnet panel and sometimes with the aspnetpanel filling the whole browser (as if it is docked to fill) and, thus, hiding the textbox (no window borders show up those times). And then the null reference always shows up.

    I'm very puzzled. Shall I keep using the 1.3.14.1 version ? Can it be related in any sense to this behaviour?

    Alex

  5. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-12-05 22:13:52 UTC

    Nothing changed in 1.3.14.1 for the session restore feature. When you run from VS if you have the aspx page open, VS will simply open the page, check the URL in the browser. If the URL in the browser is the aspx page then the Wisej session is null since you are running he aspx page by itself. Are you running the test using the IIS Development server with VS?

  6. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-12-05 22:30:12 UTC

    Whoops! You found it Luca! I was seeing the aspx page itself and NOT the window! Sorry for that. When I close it in VS (both the aspx and aspx.cs files) I get the correct result, even with 1.3.14.1 and without the session restore. Sorry for the false alert!!! Best, Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions