9

Web重温系列(一):利用寄宿于IIS的WCF序列化文件

 3 years ago
source link: https://www.cnblogs.com/ceachy/p/Web_IISHostedWCF_and_ServerFile.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Web重温系列(一):利用寄宿于IIS的WCF序列化文件

  这两年一直在做WinForm,对于Web已经比较生疏了,其实之前做的也不是很多。

  这两天做了一个小工具,功能很简单,就是想有个地方存放办公室同事的机器名和IP的信息,包括附加的用户名和更新时间。比较之后,我选择的解决方案是WCF service(hosted in IIS) + WinForm。好处是:IIS提供了可以长时间运行的服务,不用我自己起宿主程序;同时,WinForm可以简单取得本机的机器名、IP和登录用户等信息。

  Hard模式走起。我本来图方便,不想安装数据库,就是用序列化xml的方法来存储数据(这个本来是处理配置文件的手段)。结果,遇到了一堆问题325113-20190104214852806-2093747068.png,包括:

  1、线程并发(也可能是不同session)导致添加的数据被冲掉;

  2、App_Data目录没有部署,导致不知道这个目录该创建在根目录里还是bin目录里;

  3、IIS_User对于App_Data没有访问权限;

  4、默认用.net 3.5版本,只有Dictionary,没有ConcurrentDictionary,直接不能访问(仍旧怀疑跟session有关);

  5、升级到.net 4.6,又要面对设置应用程序池,补充安装ASP.Net模块,修复IIS的问题;

  6、本地文件路径如果设置,例如Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data", strFile);

  所有这些处理完之后,终于消停了325113-20190104220012279-779505108.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK