【问题标题】:Windows authorization in an asp.net mvc4 applicationasp.net mvc4 应用程序中的 Windows 授权
【发布时间】:2013-09-15 07:47:33
【问题描述】:

我的 asp.net mvc4 应用程序出现授权错误。我机器的账户管理员就是这个

我的会话属性:

在我的 web.config 文件中我把这个 sn-p:

 <authentication mode="Windows" />
    <authorization>
      <allow  users = "Lamloumi" />
      <deny users="?"/>
    </authorization>

当我启动应用程序时,我无法访问它。

这个错误的原因是什么?如何修复我的代码?

【问题讨论】:

  • here,这可能会有所帮助。之前有人问过类似的问题
  • 不,它没有改变任何东西!我看不出有什么区别。另外,如果我输入` ` 我可以访问该网站!!为什么?
  • 我把string s = User.Identity.Name;放在控制器里,s的值是空字符串!!!
  • 你可以试试这个httpcontext.current.user.identity.name
  • httpcontext 不包含属性 current !!

标签: asp.net .net asp.net-mvc-4 web-config authorization


【解决方案1】:

尝试将域名添加到allow

 <allow users="DomainName\UserName" />

【讨论】:

  • 我怎么知道域名?
  • 我这样做了&lt;allow users="myipadress\Lamloumi" /&gt;,但没有成功
  • 请查看我的编辑:我输入了&lt;deny users="WORKGROUP\Afif" /&gt;,但我仍然可以访问该应用程序
  • @Lamloumi 我没有更多的想法! :(
【解决方案2】:

尝试使用这个:

<configuration>
<authentication mode="Windows" />
  <system.web>
    <authorization>
      <allow  users = "Lamloumi" />
      <deny users="?"/>
    </authorization>
  </system.web>
</configuration>

【讨论】:

  • &lt;authentication mode="Windows" /&gt; 不能在configuration 标签之外
  • 我认为问题出在帐户上,因为如果我输入 ` ` 我可以访问应用程序
  • 我把string s = User.Identity.Name;放在控制器里,s的值是空字符串!!!
  • 你的意思是Web.config文件?
  • @Lamloumi 对不起,我认为类似的形式 auth!尝试添加域名!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-07
  • 2019-08-18
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 2014-05-21
  • 1970-01-01
相关资源
最近更新 更多