c#中webconfig的自定义方法
2015-05-11 11:16
176 查看
1.在webconfig中添加
2.新建一个cs文件
调用方法(cshtml)
<configSections> <section name="picLink" type="System.Configuration.NameValueSectionHandler"/> </configSections> <picLink> <add key="link" value="http://www.auxun.cn/"></add> </picLink>
2.新建一个cs文件
using System.Configuration; using System.Collections.Specialized; namespace PPP.Code { public static class picLinkClass { public static string getPiclink(){ NameValueCollection postinfo = (NameValueCollection)ConfigurationManager.GetSection("picLink"); return postinfo["link"]; } } }
调用方法(cshtml)
@using PPP.Code <img src="@picLinkClass.getPiclink()local/picfolder/no.jpg" style="height:100%">
相关文章推荐
- c# webconfig的自定义的使用方法
- asp.net C#中对Web.Config字符串加密与解密的方法
- 解决在Web.config或App.config中添加自定义配置的方法详解
- 在WebConfig中注册自定义HttpModule的方法
- C#中对Web.Config、App.Config字符串加密与解密的方法
- 解决在Web.config或App.config中添加自定义配置的方法详解
- C#连接数据库的新方法(通过web.config配置文件)
- C#连接数据库的新方法(通过web.config配置文件)
- 在web.config和app.config文件中增加自定义配置节点的方法
- C#连接数据库的新方法(通过web.config配置文件)
- C#中Web.Config加密与解密的方法
- C#获取web.config配置文件内容的方法
- C#获取web.config配置文件内容的方法
- C# App.config 自定义 配置节 报错“配置系统未能初始化” 解决方法
- web.config C#中使用自定义配置
- 在web.config和app.config文件中增加自定义配置节点的方法
- C# App.config 自定义 配置节 报错“配置系统未能初始化” 解决方法
- 关于ASP.NET C#配置Web.config的方法及读取方法
- asp.net c# web.config 读取web.config中自定义的参数信息,configuration section configSections
- c#里把数据库链接字符串写在web.config文件里调用方法