开发者

What is machine config in asp.net

Hai ,

I am doing a web project in asp.net. Now I am trying to keep each connection string for each user . And the user can decide which server he prefer. How to change this dynamically and where can I store this?. I happen heard about machine.config .Unfortunately i am not familiar with this. Can you just tell what it is and it's use. If any disadvantages please tell. And How 开发者_JAVA百科it use?


Machine.config is a "global" set of configuration settings. All websites on your server use the settings set in Machine.config, and they can be overridden with settings in Web.config. See Machine Configuration Files on MSDN.

If the connectionstring is unique to each user, web.config (or machine.config) is probably not the location where you'd want to store it.
But if I assume you're only going to deal with a handful of connections (i.e. NOT a unique connection per user), you could create the connections in web.config and then just store a reference for each user.

<connectionStrings>
    <add name="cnn1" connectionString="[your connectionstring]" />
    <add name="cnn2" connectionString="[your connectionstring]" />
</connectionStrings>

Where do you store user specific data? ASP.NET Membership? Something handrolled?


Its usage (I am talking for web.config):

Writing connection strings manually is difficult especially when you don't know its syntax. So,

1.Add a SqlDataSource (if your db is mssql) 2.Point it to your .mdf file 3.It will ask whether it should save it to web.config 4.say "yes" and give a name to that string 5.Now you have a connectionstring with a name 6.Then you can manipulate it


I don't advice you to use that file, it is server wide configuration file, use web.config that is application wide.

Meantime, why do you want to store connection string for each user?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜