C#: Create a WebRequest with HTTP Basic Authentication
http://blog.csdn.net/huangyaoshifog/article/details/4470675
myReq = WebRequest.Create(url);
string username="username";
string password="password";
string usernamePassword = username + ":" + password;
CredentialCache mycache = new CredentialCache();
mycache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
myReq.Credentials = mycache;
myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword)));
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
C#: Create a WebRequest with HTTP Basic Authentication的更多相关文章
- [转]OData and Authentication – Part 6 – Custom Basic Authentication
本文转自:https://blogs.msdn.microsoft.com/astoriateam/2010/07/21/odata-and-authentication-part-6-custom- ...
- Secure Spring REST API using Basic Authentication
What is Basic Authentication? Traditional authentication approaches like login pages or session iden ...
- 2. Retrofit2 -- Basic Authentication on Android
2. Retrofit2 -- Basic Authentication on Android android Retrofit tutorial 整合基本的认证 Retrofit 1.9 Retro ...
- HttpClient 三种 Http Basic Authentication 认证方式,你了解了吗?
Http Basic 简介 HTTP 提供一个用于权限控制和认证的通用框架.最常用的 HTTP 认证方案是 HTTP Basic authentication.Http Basic 认证是一种用来允许 ...
- Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...
- Nancy 学习-身份认证(Basic Authentication) 继续跨平台
开源 示例代码:https://github.com/linezero/NancyDemo 前面讲解Nancy的进阶部分,现在来学习Nancy 的身份认证. 本篇主要讲解Basic Authentic ...
- HTTP Basic Authentication
Client端发送请求, 要在发送请求的时候添加HTTP Basic Authentication认证信息到请求中,有两种方法:1. 在请求头中添加Authorization: Authoriz ...
- Web services 安全 - HTTP Basic Authentication
根据 RFC2617 的规定,HTTP 有两种标准的认证方式,即,BASIC 和 DIGEST.HTTP Basic Authentication 是指客户端必须使用用户名和密码在一个指定的域 (Re ...
- Web API 基于ASP.NET Identity的Basic Authentication
今天给大家分享在Web API下,如何利用ASP.NET Identity实现基本认证(Basic Authentication),在博客园子搜索了一圈Web API的基本认证,基本都是做的Forms ...
随机推荐
- iOS 简单block的使用
1.第一种方法 声明block: - (void)test:(int) param_1 completion:(void(^)(int)) completion; 实现block: -(void)te ...
- Programmer's Jokes
1. 一天, 下着小雨, 和同事们一起去上班,一位同事差点滑倒,另一位同事笑话说:如果人走路用爬的就不会摔倒了! 遂反问他:能用两行代码搞定的事情为什么要用4行呢? 2. 有趣的公式( Fr ...
- Part 36 to 39 Talking about Delegates in c#
Part 36 Delegates in c# Part 37 Delegates usage in c# class Progim { public static void Main() { Lis ...
- php中magic_quotes_gpc对unserialize的影响
昨天朋友让我帮他解决下他网站的购物车程序的问题,程序用的是PHPCMS,换空间前是好的(刚换的空间),具体问题是提示成功加入购物车后跳转到购物车页面,购物车里为空. 我看了下代码,大致的原理就是将产品 ...
- Oracle数据库对象_同义词
同义词是一种数据库对象,它是为一个数据库对象定义的别名,使用同义词的主要目的是为了简化SQL语句的书写. 同义词的概念和类型 利用同义词可以为用户的一个对象,或者其他用户的一个对象定义别名,从而简化命 ...
- 20140213-想念是while里的死循环
// stdafx.h : 标准系统包含文件的包含文件,// 或是经常使用但不常更改的// 特定于项目的包含文件// #pragma once#include "targetver.h&qu ...
- 对match() 和 exec() 返回值和属性的测试
语法: exec() : RegExpObject.exec(string) match() : stringObject.match(string) stringObject.match(regex ...
- 《HTML5与CSS3基础教程》学习笔记 ——Three Day
第十一章 1. box-sizing:border-box(让宽度和高度包含内边距和边框) 2. clear让后面的元素显示在浮动元素的后面 3. z-index只对只对绝对.固定.相对定位的元 ...
- mysql颠覆实战笔记(五)--商品系统设计(二):定时更新商品总点击量
继续回到沈老师的MYSQL颠覆实战,首先回顾下上一节课的内容,请大家会看下上节课写的存储过程. 打开prod_clicklog表, 我们只要把日期(不含时分秒)的部分存在数据库中, 如果同一日期有相同 ...
- 在C#用HttpWebRequest中发送GET/HTTP/HTTPS请求【转载】
标签:C# HTTPS HttpWebRequest HTTP HttpWebResponse 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任. ...