使用XML文件读取Web服务器.NET上的设置 [英] Using an XML file to read settings on a Web server .NET

查看:78
本文介绍了使用XML文件读取Web服务器.NET上的设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果多个客户端连接到服务器会发生什么?

客户端实例如何能够多次访问xml文件?我说的是一个简单的示例,例如从web.config文件中读取连接字符串.

这是ASP.NET应用程序.我将一些设置存储在xml文件中.每次用户单击提交按钮时,asp.net应用程序都会从​​xml文件读取数据.如果多个客户端同时单击提交"按钮,会发生什么情况?

What happens if multiple clients are connected to the server?

How would the instances of the client be able to access the xml file multiple times? I am talking about a simple example like reading a connection string from the web.config file.

This is ASP.NET application. I some setting stored in a xml file. Every time the user clicks on a submit button, the asp.net application reads data from a xml file. What is going to happen if multiple clients click the submit button at the same time?

推荐答案

这真的不应该是问题:只需打开一个进程如果要写入文件,则以独占模式访问该文件.只要使用FileShare.Read访问权限打开同一文件,许多进程就可以读取该文件.由于尝试写入Web.Config非常不寻常,因此没有问题.

尝试一下:设置winforms并多次打开同一文件,而又不要让流脱离上下文!
It really shouldn''t be a problem: a process only needs to open the file in exclusive mode if it is going to write to the file. Many processes can read from the same file, provided it is opened with FileShare.Read access. Since it is very unusual to try to write to Web.Config, there is no problem.

Try it: Set up a winforms and open the same file many times without letting the streams go out of context!


这篇关于使用XML文件读取Web服务器.NET上的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆