asp.net – 如何以编程方式将SMTP服务器详细信息存储(保存)回web
发布时间:2020-12-16 09:59:04 所属栏目:asp.Net 来源:网络整理
导读:搜索StackOverflow,我找到了 this question on how to Retrieve SMTP settings from Web.Config,但没有关于如何将SMTP更新回web.config文件的详细信息. 我从以下代码开始: Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("~");Ma
搜索StackOverflow,我找到了
this question on how to Retrieve SMTP settings from Web.Config,但没有关于如何将SMTP更新回web.config文件的详细信息.
我从以下代码开始: Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("~"); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)webConfig.GetSectionGroup("system.net/mailSettings"); SmtpSection smtp = settings.Smtp; SmtpNetworkElement net = smtp.Network; 但很快就被Intellisense认为SmptSection.Network是一个Get(又名“只读”)访问器. 那么我应该如何以编程方式将我的SMTP数据写回web.config呢? 解决方法
你应该可以做这样的事情,这有用吗?:
Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("~"); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)webConfig.GetSectionGroup("system.net/mailSettings"); SmtpSection smtp = settings.Smtp; SmtpNetworkElement net = smtp.Network; net.Port = 25; net.Host = "localhost"; webConfig.Save(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 身份使用Web API授权属性角色
- 如何在ASP.Net中设置TextBox的默认按钮?
- 使用Asp.net Web API时,使用DataContract和DataMember属性有
- asp.net-mvc – HTMLHelper,从属性中生成“Expression> exp
- ASP.NET 打开新页面或页面跳转
- Response.Redirect()vs Response.RedirectPermanent()
- asp.net – 如何让静态Html页面通过IIS7.0中的HttpModule?
- asp.net – Umbraco CMS(.NET):加载xslt /用户控件的日志错
- controls – mvc显示模板中当前项的索引
- asp.net-mvc – MVC会话过期而不是身份验证
推荐文章
站长推荐
- asp.net-mvc – 使用令牌认证访问Web Api的MVC .
- 捕获到ASP.NET ASMX Web服务的SOAP请求
- asp.net-mvc-3 – 在Kendo网格中显示datetime字段
- 如何将组名应用于asp.net中的HTML单选按钮?
- asp.net-mvc – 了解nopCommerce的MVC标签
- asp.net – 如何在Identity 3.0中获取当前的User
- asp.net-core – 使用ASP.NET Core从`project.js
- asp.net-mvc – MVC角色授权
- asp.net – 为什么有2个web.config文件
- asp.net – 只包含一个CSS文件
热点阅读