asp.net – 错误:远程服务器返回错误:(401)未经授权
发布时间:2020-05-24 01:57:33 所属栏目:asp.Net 来源:互联网
导读:我想要获取互联网的图片并插入字词. 我使用这段代码. MainDocumentPart mainPart = wordprocessingDocument.MainDocumentPart;System.Net.WebRequest request = System.Net.HttpWebRequest.Create(http://spsdev2:1009);System.Ne
|
我想要获取互联网的图片并插入字词. 我使用这段代码. MainDocumentPart mainPart = wordprocessingDocument.MainDocumentPart;
System.Net.WebRequest request =
System.Net.HttpWebRequest.Create("http://spsdev2:1009");
System.Net.WebResponse response = request.GetResponse();
ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg);
//Send an HTTP request and get the image at the URL as an HTTP response
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(fileName);
WebResponse myResp = myReq.GetResponse();
//Get a stream from the webresponse
Stream stream = myResp.GetResponseStream();
我在myReq.GetResponse()中得到错误; 错误:远程服务器返回错误:(401)未经授权. 编辑 这段代码为我工作:) myReq.UseDefaultCredentials = true; myReq.PreAuthenticate = true; myReq.Credentials = CredentialCache.DefaultCredentials; 解决方法我添加了HttpWebRequest的凭据.myReq.UseDefaultCredentials = true; myReq.PreAuthenticate = true; myReq.Credentials = CredentialCache.DefaultCredentials; (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 更改用户登录名后的身份验证错误
- asp.net – ApplicationInsight导致网站在启动时挂起
- asp.net-mvc – ASP.NET MVC FileStreamResult不能按预期工
- asp.net – SqlException(0x80131904):第28行:(‘.)附近的
- asp.net-mvc – Razor MVC模型正在丢失保存操作的数据
- 在ASP.NET Web API的JSON输出中没有时间的日期
- asp.net – 如何直接在.aspx页面中访问web.config设置?
- Modular Web Application with ASP.NET Core
- Asp.net MVC Razor – 自定义javascript里面的if块
- asp.net – ASP.MVC CORE网站的最大上传大小
推荐文章
站长推荐
- asp.net-mvc – HandleErrorAttribute无法正常工
- asp.net-mvc – Kendo:处理Ajax数据请求中的错误
- asp.net-mvc – 如何在Visual Studio 2008和ASP.
- 如何从asp.net调用Windows服务
- ASP.net应用程序崩溃 – 无法加载文件或程序集“
- asp.net – 来自WebHttpBinding的WCF服务中的Acc
- ASP.NET MVC验证属性和Jquery
- asp.net – 如何接收JSON作为MVC 5操作方法参数
- asp.net-web-api – 认证/授权MVC 5和Web API –
- asp.net-core – 虚拟目录中的IIS站点Swagger UI
热点阅读
