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

Zyciis197 2008-12-11 05:54:01
以下是慕白兄提供 在文件系统中是可以用的,但是在IIS中不行
那IIS要怎么设置呢

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();




救命啊
...全文
576 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
yt6901072 2009-09-05
  • 打赏
  • 举报
回复
工行开发QQ交流1227385358
Zyciis197 2008-12-11
  • 打赏
  • 举报
回复
RE:还是不行?Everyone设置到管理员的组
-----------------
OK了 先结贴再开一贴问
beikehanbao23 2008-12-11
  • 打赏
  • 举报
回复
a
criedshy 2008-12-11
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 Zyciis197 的回复:]
RE:在要读取的文件上右键--安全与共享(或属性--安全)--添加--找到以“IUSR_”开头的用户,加上权限
------------------------------------------
这个的话我已经添加了Everyone了 权限都为最大了
谢谢
[/Quote]

还是不行?Everyone设置到管理员的组
Zyciis197 2008-12-11
  • 打赏
  • 举报
回复
RE:在要读取的文件上右键--安全与共享(或属性--安全)--添加--找到以“IUSR_”开头的用户,加上权限
------------------------------------------
这个的话我已经添加了Everyone了 权限都为最大了
谢谢
niitnanfeng 2008-12-11
  • 打赏
  • 举报
回复
你没配置过网站吗?
supremeholy 2008-12-11
  • 打赏
  • 举报
回复
在要读取的文件上右键--安全与共享(或属性--安全)--添加--找到以“IUSR_”开头的用户,加上权限
Zyciis197 2008-12-11
  • 打赏
  • 举报
回复
因为星期一就要得 总公司下来的总监做演示
但这些网站那时候上面又说暂时停下来
而这个时候又突然间要

所以可能没有那么多的时间去做研究
就麻烦各位了

谢谢
Zyciis197 2008-12-11
  • 打赏
  • 举报
回复
RE:给ASPNET用户读写文件的权限
在哪里改

谢谢
criedshy 2008-12-11
  • 打赏
  • 举报
回复
你的代码涉及到了读写文件,所以就有权限的问题了
criedshy 2008-12-11
  • 打赏
  • 举报
回复
403 是禁止访问或者文件不存在


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

给ASPNET用户读写文件的权限
wangping_li 2008-12-11
  • 打赏
  • 举报
回复
被禁止?是不是安全问题引起的?
Up
Zyciis197 2008-12-11
  • 打赏
  • 举报
回复
不要只顶帮帮忙啊
mengxj85 2008-12-11
  • 打赏
  • 举报
回复
有意思,顶
Zyciis197 2008-12-11
  • 打赏
  • 举报
回复
哈哈 1200
gongsun 2008-12-11
  • 打赏
  • 举报
回复
哥们,您到底开了多少号?

62,052

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧