【问题标题】:How to get user name and password from url in ASP.NET?如何从 ASP.NET 中的 url 获取用户名和密码?
【发布时间】:2011-03-17 20:09:57
【问题描述】:

如何从 URL 中获取 ASP.NET 用户名和密码?

https://myUser:myPassword@myServer/

HttpContext.Current.Request.Url 正在返回 https://myServer/

【问题讨论】:

    标签: c# .net asp.net iis url


    【解决方案1】:

    您需要访问身份验证标头。

    有关 HTTP 身份验证的信息: http://en.wikipedia.org/wiki/Basic_access_authentication

    在 asp.net 中实现: http://blog.smithfamily.dk/2008/08/27/ImplementingBasicAuthenticationInASPNET20.aspx

    【讨论】:

    • 第二个链接坏了。
    【解决方案2】:

    实际上,完全有可能在没有 HTTP 授权标头的 URL 中包含 URI 凭据。要提取这些,由于 Request.Url 属性是一个 Uri 对象,您可以在 Uri.UserInfo 属性中访问这些详细信息。

    【讨论】:

    • IIS 似乎没有将UserInfo 传递给HttpContext.Current.Request.Url
    猜你喜欢
    • 1970-01-01
    • 2021-12-27
    • 1970-01-01
    • 2014-08-24
    • 2014-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-07
    相关资源
    最近更新 更多