0

The question(s) might be silly because i donot have much knowledge about framework 1.1

I'm trying to share the Application level variable among two different .net applications. one is .net 1.1 and the other is .net 4.0.

Here is the scenario:

I've created an application(App11) which targets .Net Framework 1.1 using Visual Studio 2003. I've also created a web site(App40) which targets .Net Framework 4.0 in Visual Studio 2010.

I've added the App40 in the App11, i've hosted App11 in IIS 5.1. Now App40 is a folder in App11.

App40 has the application pool with framework 4.0 and App11 has the application pool with framework 1.1.

I donot have much of knowledge in .Net Framework 1.1. So,i've google and found state management techniques for .Net Framework 1.1. It seems like Framework 1.1 supports Application State

I thought the Application management would work. So, i've tried like this:

In the App11 í've defined a Application variable in the Application_Start() of Global.asax.

protected void Application_Start(Object sender, EventArgs e)
        {
            Application["AppDATA"]="Application Data";
        }

I've a Default.aspx page in App11 application. The Default page has a hyperlink to redirect to the App40/Default.aspx page.

In the Codebehind file of Default.aspx in App40 i've done like this:

//Application State check
        if (Application["AppDATA"] != null)
        {
            applicationState.Text = "Got application state data :"+Application["AppDATA"].ToString();
        }
        else
        {
            applicationState.Text = "Application State failed to work !";
        }

I've builded both the applications and stated with Default page of App11.

When i click on the link i could not see any Application data that has come from the Framework 1.1, it only shows Application State failed to work ! message on the page.

Does this work ? or Am i trying these things stupid ?

Do i need to setup anything in addition to the things i've done ?

4

4 回答 4

1

据我所知,您的应用程序级别变量位于应用程序级别,因此如果您有 2 个不同的应用程序,它们不共享变量似乎很合逻辑。我认为您需要使用文件、数据库甚至网络服务在不同的应用程序之间共享数据......

于 2013-04-03T11:17:31.550 回答
0

不可能按照您尝试的方式进行。与具有不同模式(内存、sql、会话服务器)的会话状态不同,应用程序状态始终存储在内存中。不同应用程序池中的应用程序运行在不同的进程中,因此无法直接共享这些信息。您需要将数据存储在一个进程中并使用某种 IPC。有很多可能性:SQL、Remoting、WCF、Web 服务等。

请注意,即使它们在同一个应用程序池中,它们也不会自动共享应用程序状态,因为它们将在不同的应用程序域中运行。但是如果没有操作系统隔离,它们之间的共享会更容易。

于 2013-04-03T16:06:54.757 回答
0

您要跨应用程序共享状态的唯一方法是某种持久性(数据库、cookie、查询字符串......)

于 2013-04-03T16:12:17.273 回答
0

不,您不能只是简单地在您指定的应用程序之间共享数据(至少这是我所知道的)。

您需要将数据存储到 XML 文件等外部位置。一个应用程序会将数据写入文件,而其他应用程序可以读取它。或者你可以让他们两个做同样的事情。

您还可以使用数据库来存储数据。这也可以像我提到的 XML 文件一样工作。

我希望我能帮上忙。

于 2013-04-03T12:13:28.140 回答