|zyciis| 超急 网站添加工商银行网上支付的工能,在用代码去取数据的时候如果在文件系统中是OK的,但是如果是在IIS中就出错 快帮帮忙 多谢

|zyciis| 超急 网站添加工商银行网上支付的工能,在用代码去取数据的时候如果在文件系统中是OK的,但是如果是在IIS中就出错 快帮帮忙 谢谢
以下是慕白兄提供 在文件系统中是可以用的,但是在IIS中不行
那IIS要怎么设置呢
C# code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Runtime.InteropServices;
using System.Security.Cryptography.X509Certificates;
using System.Net;
using System.Security.Cryptography;
using System.Web;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        String xml = System.Web.HttpContext.Current.Server.UrlDecode(CheckOrder());
        Response.Write(xml);
        Response.End();
    }

    String CheckOrder()
    {
        ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
        string Url = "https://corporbank.icbc.com.cn/servlet/ICBCINBSEBusinessServlet";
        HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(Url);
        String crtFile = @"D:\ICBC\mybank.crt";
        X509Certificate C509 = X509Certificate.CreateFromCertFile(crtFile);
        req.ClientCertificates.Add(C509);

        ICBCEBANKUTILLib.B2CUtilClass obj = new ICBCEBANKUTILLib.B2CUtilClass();
        obj.init(@"D:\ICBC\WebPayebb2cpublic.crt", @"D:\ICBC\mybank.crt", @"D:\ICBC\mybank.key", "abcdefgh");

        //string APIName = "EAPI";ICBC_PERBANK_B2C
        string APIName = "EAPI";
        //APIName = obj.signC(APIName, APIName.Length);
        // 接口版本号
        string APIVersion = "001.001.002.001";

        // APIVersion = obj.signC(APIVersion, APIVersion.Length);
        // 订单号
        string orderNum = "0812100002-20081211153520";
        //string orderNum = "";
        // 交易日期
        string tranDate = DateTime.Now.ToString("yyyyMMdd");
        //string tranDate = "";
        // 商家号码
        string ShopCode = "1001EC200012121";
        // 商城帐号
        string ShopAccount = "10023420719016132421";
        string PostData = "APIName=" + APIName + "&APIVersion=" + APIVersion + "&MerReqData=" +

            System.Web.HttpUtility.UrlEncode("<?xml  version=\"1.0\" encoding=\"GBK\" standalone=\"no\" ?><ICBCAPI><in><orderNum>" + orderNum + "</orderNum><tranDate>" + tranDate + "</tranDate><ShopCode>" + ShopCode + "</ShopCode><ShopAccount>" + ShopAccount + "</ShopAccount></in></ICBCAPI>", System.Text.Encoding.Default);
        byte[] buffer = Encoding.GetEncoding("GBK").GetBytes(PostData);

        req.Method = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        req.KeepAlive = true;
        req.ContentLength = buffer.Length;

        System.IO.Stream strmRequet = req.GetRequestStream();
        if (strmRequet.CanWrite)
        {


            strmRequet.Write(buffer, 0, buffer.Length);
            strmRequet.Close();
            strmRequet = null;
        }

        HttpWebResponse res = (HttpWebResponse)req.GetResponse();
        System.IO.Stream stream = res.GetResponseStream();

        //DataSet ds = new DataSet();
        //ds.ReadXml(stream);
        System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
        //doc.Load(stream);

        System.IO.StreamReader sr = new System.IO.StreamReader(stream, System.Text.Encoding.Default);
        string str = sr.ReadToEnd();
        sr.Close();
        res.Close();
        return str;
    }
    internal class AcceptAllCertificatePolicy : ICertificatePolicy
    {

        public AcceptAllCertificatePolicy()
        {
        }

        public bool CheckValidationResult(ServicePoint sPoint, X509Certificate cert, WebRequest wRequest, int certProb)
        {

            return true;

        }

    }
}



出错提示:

远程服务器返回错误: (403) 已禁止。
87: HttpWebResponse res = (HttpWebResponse)req.GetResponse();




救命啊

------解决方案--------------------
哥们,您到底开了多少号?
------解决方案--------------------
有意思,顶
------解决方案--------------------
被禁止?是不是安全问题引起的?
Up
------解决方案--------------------
403 是禁止访问或者文件不存在


是不是你的访问权限不够啊?

给ASPNET用户读写文件的权限
------解决方案--------------------
你的代码涉及到了读写文件,所以就有权限的问题了
------解决方案--------------------
在要读取的文件上右键--安全与共享(或属性--安全)--添加--找到以“IUSR_”开头的用户,加上权限
------解决方案--------------------
你没配置过网站吗?
------解决方案--------------------
探讨
RE:在要读取的文件上右键--安全与共享(或属性--安全)--添加--找到以“IUSR_”开头的用户,加上权限
------------------------------------------
这个的话我已经添加了Everyone了 权限都为最大了
谢谢

------解决方案--------------------
a