在web.config中编辑设置 [英] Edit Settings in web.config

查看:186
本文介绍了在web.config中编辑设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道标题怎么这个问题 - 我想提出一个请求到PayPal的前preSS支付API。我用自己的DLL,它有助于使请求和解析响应。他们的code工作的指示是在的web.config 文件中添加你的授权证书。我已经这样做了。我的问题是,我希望能够编辑这些凭据正在动态设置(可能是从SQL了),因为我们要允许不同的用户输入自己的API证书。发送请求到PayPal看起来像这样

I didn't know how to title this question - I am making a request to PayPal's Express Payment API. I'm using their dll that helps make the request and parse the response. The instructions for their code to work is to add you authorization credentials in the web.config file. I have done so. My problem is that I want to be able to edit these credentials that are being set dynamically (probably got from SQL) because we are going to allow different users to enter their API credentials. Sending the request to PayPal looks like this

    Dim wrapper As New SetExpressCheckoutReq()
    wrapper.SetExpressCheckoutRequest = request
    Dim service As New PayPalAPIInterfaceServiceService()
    Dim setECResponse As SetExpressCheckoutResponseType = service.SetExpressCheckout(wrapper)

这里没有多少空间存在编辑请求的头,因为 PayPalAPIInterfaceServiceService()定义他们的DLL和应用基础上的凭据它自己的头web.config中。

There's not much room in there to edit the header of the request, because PayPalAPIInterfaceServiceService() is defined in their dll and applies its own header based on the credentials in the web.config.

所以,我的问题是,有没有办法指向了的web.config 到另一个位置时,它会在的web.config ?我不知道这是可能的。此外,有没有什么办法可以编辑在一个DLL中定义不改变该DLL的请求的报头(留符合PCI标准)

So, my question is, is there a way to point in the web.config to another location when it looks in web.config? I'm not to sure this is possible. Also, is there any way to edit the header of a request that is defined in a dll without changing the dll (to stay pci compliant)

下面是在web.config行:

Here is the line in the web.config:

 <account apiUsername="****" apiPassword="****" apiSignature="****"/>

编辑:

我知道这是不好的添加或编辑的web.config动态,我一直在寻找更多的方式来指向到其他位置,可以进行编辑。像在C#code,你可以写设置[字符串] 和点到web.config中。有没有办法在web.config指向该项目的位置,这个位置可以动态改变

I know it is bad to add or edit web.config dynamically , I was looking more for a way to point to another location that can be edited. Like in C# code you could write Settings["string"] and that points into the web.config. Is there a way in the web.config to point to a location in the project , and this location could be changed dynamically

推荐答案

我同意iefpw的手动修改web.config文件是个坏消息,但既然你问的 WebConfigurationManager 提供你正在寻找的功能。

I agree with iefpw that modifying a web.config file manually is bad news, but since you asked, WebConfigurationManager provides the functionality you are looking for.

这类有一个<一个href="http://msdn.microsoft.com/en-us/library/system.configuration.configuration.save%28v=vs.100%29.aspx"相对=nofollow>可以叫你做了更改后,保存方法。我只用WebConfigurationManager读取web.config文件中,所以不必为你code例子。祝你好运。

That class has a Save method that can be called after you've made your changes. I've only used WebConfigurationManager for reading web.config files, so don't have a code example for you. Good luck.

这篇关于在web.config中编辑设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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