简体   繁体   中英

Is it possible to share Application data between .net 1.1 and .net 4.0 applications

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 ?

As far as I see it, your application level variables are on application level, so if you have 2 different applications it seems quite logic they're not sharing variables. I think you need to use a file , a database or even a webservice to share data among different applications...

No, you cannot just simply share data between your specified applications (at least that's what I know).

You would need to store data to an external place like an XML file. One application would write the data to the file, and other can read it. Or you can make both of them do the same thing.

You can also use a database to store the data. This would also work like I mentioned with a XML file.

I hoped I helped.

It's not possible to do it the way you are trying. Unlike Session state which has different modes (in memory, sql, session server) Application state is always stored in memory . Applications in different application pools run in different processes, so it's not possible to directly share this information. You'll need to store the data in one process and use some kind of IPC. There are many possibilities: SQL, Remoting, WCF, web service, etc.

Note that even if they were in the same application pool they wouldn't automatically share Application state, since they would be running in different App Domains. But without the OS isolation, it would be easier to share between them.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM