I have one solution that contains 3 projects : ASP.net MVC 4.0, Share Library and Web Service project. I want to share some of key value in appSettings of Web.Config in ASP.net mvc Project to Web Service Project. I found this answer but it's now working for me.
Could anyone give me some idea please.
Thanks you so much.
You could store that information into a dll that you would share accross all your projects :
Create a new Class Library project :
Name your class MyConfiguration.cs for example
namespace CentralizedInformation
{
public static class MyConfiguration
{
public static string Value1 = "Test string value 1";
public static int Value2 = 2;
}
}
After you can add the reference in all your projects (Project -> add reference -> Browse -> Browse to CentralizedInformation.dll)
and add itin your projects (here an mvc project example)
using CentralizedInformation;
//for asp net mvc project
protected void Application_Start()
{
string mySharedAccrossAllProjectsString = CentralizedInformation.MyConfiguration.Value1;
//put it wherever you need it session or anything else
}
Juste reference the same in your other projects and you are done. Also rebuild your projects when you want to update the data ...
That dll could have a config file and you could programmatically expose all it's data.
I admit it's a quite funny and complicated way to do such a simple thing. But that's a way ^^
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.