摘要:
http://stackoverflow.com/questions/10861568/asmx-web-service-basic-authentication//-----------------------------------------------------public class BasicAuthHttpModule:IHttpModule{ voidIHttpModule.Init(HttpApplication context) { context.AuthenticateRequest+=newEventHandler(OnAuthenticateRequest); } 阅读全文
posted @ 2012-12-15 20:29
火腿骑士
阅读(387)
评论(0)
推荐(0)
摘要:
publicclassUserAuthenticator:IHttpModule{ publicvoidDispose() { } publicvoidInit(HttpApplication application) { application.AuthenticateRequest+=newEventHandler(this.OnAuthenticateRequest); application.EndRequest+=newEventHandler(this.OnEndRequest); } publicvoidOnAuthenticateRequest(object source,Ev 阅读全文
posted @ 2012-12-15 19:47
火腿骑士
阅读(231)
评论(0)
推荐(0)
摘要:
什么是HTTP Basic Authentication?在wiki上有详细的解释: http://en.wikipedia.org/wiki/Basic_authentication_schemeHTTP Basic Authentication是一个定义在HTTP/1.1规范中的验证机制。这种机制是以用户名和密码为基础的。一个web server要求一个web client去验证一个用户。作为request的一部分,web server 传递被称之为realm的字符串,用户就是在它里面被验证的。注意:Basic Authentication机制的realm字符串不一定反映任何一种安全方针域 阅读全文
posted @ 2012-12-15 19:42
火腿骑士
阅读(884)
评论(0)
推荐(0)
摘要:
http://www.cnblogs.com/yingzi/archive/2012/03/13/2394809.htmlHTTP请求格式当浏览器向Web服务器发出请求时,它向服务器传递了一个数据块,也就是请求信息,HTTP请求信息由3部分组成:l请求方法URI协议/版本l请求头(Request Header)l请求正文下面是一个HTTP请求的例子:GET/sample.jspHTTP/1.1Accept:image/gif.image/jpeg,*/*Accept-Language:zh-cnConnection:Keep-AliveHost:localhostUser-Agent:Mozi 阅读全文
posted @ 2012-12-15 19:39
火腿骑士
阅读(1559)
评论(0)
推荐(0)
摘要:
不同于之前的HttpWebRequest类型,在.NET 4.5中新的HttpRequestHeaders类型直接有一个Authorization属性,对应类型是:AuthenticationHeaderValue,同样在System.Net.Http.Headers命名空间内。AuthenticationHeaderValue有两个属性Parameter和Scheme。为了弄清这两个参数在对Authorization属性的作用,我们可以做一个简单的测试:首先得记得加入.NET 4.5中HttpClient相应的命名空间://+ using System.Net.Http;//+ using 阅读全文
posted @ 2012-12-15 19:32
火腿骑士
阅读(368)
评论(0)
推荐(0)
摘要:
Implementing Basic Authentication in ASP.NET 2.0ByAdministrator27. 八月 2008 20:35I have many times wanted to implement basic authentication in asp.net applications, but has been unwilling to use the built in basic authentication of IIS, since I think its a bother to use either the Windows machine' 阅读全文
posted @ 2012-12-15 19:20
火腿骑士
阅读(256)
评论(0)
推荐(0)
摘要:
var http = require('http');var server = http.createServer(function(req, res) {// console.log(req); // debug dump the request// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object) 阅读全文
posted @ 2012-12-15 19:16
火腿骑士
阅读(198)
评论(0)
推荐(0)
摘要:
HTTP使用BASIC认证的原理及实现方法上一篇/下一篇2011-10-19 15:56:15 / 个人分类:java查看( 4555 )/评论( 5 )/评分(10/0)一.BASIC认证概述在HTTP协议进行通信的过程中,HTTP协议定义了基本认证过程以允许HTTP服务器对WEB浏览器进行用户身份证的方法,当一个客户端向HTTP服务器进行数据请求时,如果客户端未被认证,则HTTP服务器将通过基本认证过程对客户端的用户名及密码进行验证,以决定用户是否合法。客户端在接收到HTTP服务器的身份认证要求后,会提示用户输入用户名及密码,然后将用户名及密码以BASE64加密,加密后的密文将附加于请求信 阅读全文
posted @ 2012-12-15 19:06
火腿骑士
阅读(291)
评论(0)
推荐(0)
摘要:
BasicAuthMessageHandler1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950publicclassBasicAuthMessageHandler:DelegatingHandler{privateconststringBasicAuthResponseHeader="WWW-Authenticate";privateconststringBasicAuthResponseHeaderValue="Basic&quo 阅读全文
posted @ 2012-12-15 17:54
火腿骑士
阅读(536)
评论(0)
推荐(0)
摘要:
using System;using System.Net;using System.Security.Cryptography;using System.Security.Cryptography.X509Certificates;using System.Security.Principal;using System.ServiceModel.Channels;using System.Threading;using System.Web.Http;using System.Web.Http.Controllers;using System.Web.Http.Filters;using D 阅读全文
posted @ 2012-12-15 17:50
火腿骑士
阅读(715)
评论(0)
推荐(0)
摘要:
http://stackoverflow.com/questions/11135473/how-to-use-an-authorized-username-in-other-controllershttp://stackoverflow.com/questions/12227495/httpactioncontext-request-headers-authorization-is-null//----------------------------------------------------------------------------------Posted on June 10, 阅读全文
posted @ 2012-12-15 17:38
火腿骑士
阅读(696)
评论(0)
推荐(0)
摘要:
使用asp.net mvc3的Filter模拟实现http basic Authentication近段时间,在编写一个淘宝家园的手机客户端,需要一个配套的api提供服务,使用http basic验证来确认用户。在iis7上架了一个api的测试站点,iis默认的http basic 验证需要和windows的用户绑定在一起,无法将用户认证和业务数据中的用户进行对应关联。查询相关资料后,准备使用mvc的filter模拟实现http basic authentication,也方便在实现api时对验证和非验证的调整。1.vs2010中建立asp.net mvc3 web项目2.添加用户验证filt 阅读全文
posted @ 2012-12-15 17:25
火腿骑士
阅读(266)
评论(0)
推荐(0)
摘要:
Asp.net MVC中Controller返回值类型在mvc中所有的controller类都必须使用"Controller"后缀来命名并且对Action也有一定的要求:必须是一个public方法必须是实例方法没有标志NonActionAttribute特性的(NoAction)不能被重载必须返回ActionResult类型如:[csharp]view plaincopypublicclassMyController:Controller{//必须返回ActionResult类型publicActionResultHelloWorld(){ViewData["Me 阅读全文
posted @ 2012-12-15 17:11
火腿骑士
阅读(197)
评论(0)
推荐(0)
摘要:
http://blogs.msdn.com/b/scottgu/archive/2011/05/23/asp-net-mvc-3-razor-helper.aspxhttp://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspxhttp://blog.joycode.com/scottgu/archives/2010/12/30/116202.joyASP.NET MVC 3: Razor中的@:和语法By devdivchina | Published 阅读全文
posted @ 2012-12-15 14:27
火腿骑士
阅读(225)
评论(0)
推荐(0)
摘要:
ASP.NET MVC 3:缓存功能的设计问题2011年12月19日16:14来源:博客作者:陈希章 编辑:苏巧红评论:0条 【IT168技术】今天这一篇文章我来谈一谈在MVC 3项目中的缓存功能,以及针对缓存的一些设计上的考量,给大家参考参考。 为什么需要讨论缓存?缓存是一个中大型系统所必须考虑的问题。为了避免每次请求都去访问后台的资源(例如数据库),我们一般会考虑将一些更新不是很频繁的,可以重用的数据,通过一定的方式临时地保存起来,后续的请求根据情况可以直接访问这些保存起来的数据。这种机制就是所谓的缓存机制。 根据缓存的位置不同,可以区分为: ①客户端缓存(缓存在用户的客户端,例如... 阅读全文
posted @ 2012-12-15 13:53
火腿骑士
阅读(198)
评论(0)
推荐(0)
摘要:
Creating a REST service using ASP.NET Web APIByAfter2050,13 Sep 20124.33(3 votes)IntroductionA service that is created based upon the architecture ofRESTis called as REST service. Although REST looks more inclined to web and HTTP its principles can be applied to other distributed communication syste 阅读全文
posted @ 2012-12-15 13:03
火腿骑士
阅读(386)
评论(0)
推荐(0)
摘要:
public Task Get(int id){ var task = _taskRepository.Get(id); if (task == null) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Task not found") }); } return task;}public Task Put(Task task){ try { task = _taskRe 阅读全文
posted @ 2012-12-15 12:55
火腿骑士
阅读(230)
评论(0)
推荐(0)