【发布时间】:2011-03-17 20:09:57
【问题描述】:
如何从 URL 中获取 ASP.NET 用户名和密码?
https://myUser:myPassword@myServer/
HttpContext.Current.Request.Url 正在返回 https://myServer/。
【问题讨论】:
如何从 URL 中获取 ASP.NET 用户名和密码?
https://myUser:myPassword@myServer/
HttpContext.Current.Request.Url 正在返回 https://myServer/。
【问题讨论】:
您需要访问身份验证标头。
有关 HTTP 身份验证的信息: http://en.wikipedia.org/wiki/Basic_access_authentication
在 asp.net 中实现: http://blog.smithfamily.dk/2008/08/27/ImplementingBasicAuthenticationInASPNET20.aspx
【讨论】:
实际上,完全有可能在没有 HTTP 授权标头的 URL 中包含 URI 凭据。要提取这些,由于 Request.Url 属性是一个 Uri 对象,您可以在 Uri.UserInfo 属性中访问这些详细信息。
【讨论】:
UserInfo 传递给HttpContext.Current.Request.Url。