如何使用桌面应用程序更新ASP.NET的web.config文件 [英] How to update web.config file of ASP.NET using desktop application

查看:103
本文介绍了如何使用桌面应用程序更新ASP.NET的web.config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个桌面应用程序在每次使用此桌面应用程序发布新版本时更新网站我想以编程方式更新网站的Web.config文件。



请任何人建议最好的方式。



我尝试过:



我尝试使用Configuration configuration = WebConfigurationManager.OpenWebConfiguration(〜);但是在桌面System.Web.Configuration命名空间中找不到。



我还有其他方式使用read作为xml而不是继续但是它的添加/更新/删除效率不高任何级别的配置标记。

I have one desktop application to update the website whenever new release comes using this desktop app I want to update "Web.config" file of website programmatically.

Please any one suggest best way for this.

What I have tried:

I tried using Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~"); but in desktop System.Web.Configuration namespace not found.

I have other way using read as xml and than proceed but its not efficient way for Add/Update/Delete configuration tag at any level.

推荐答案

asp.net中不支持允许远程发生。如果您有对服务器的文件访问权限,则将其作为普通文件副本进行,因此请将新配置文件复制到



\\servername \ sharename \ web.config







\\ipaddress\c
There is no support in asp.net for allowing this to happen remotely. If you have file access to the server then do it as a normal file copy, so copy the new config file to

\\servername\sharename\web.config

or

\\ipaddress\c


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\如果您的桌面没有对Web服务器的文件访问权限,那么下一个最简单的方法是在您的网站上拥有一个上传功能,该功能需要上传的web.config文件并覆盖它与上传的文件。然后,您的桌面应用程序将使用WebClient或其他任何方式以编程方式将文件上载到URL。您也想考虑这种安全问题。
\inetpub\wwwroot\web.config

or whatever your access is. If your desktop has no file access to the web server then the next easiest approach would be to have an upload function on your website that takes an uploaded web.config file and overwrites the one it has with the uploaded one. Your desktop app would then upload the file to the url programatically using WebClient or whatever. You'd want to consider the security implications of this too.


这篇关于如何使用桌面应用程序更新ASP.NET的web.config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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