Skip to main content

asp.net Form验证中对不同路径使用不同的控制

这两天做新项目,把自己的碰到的问题说说。

做Web的东西,自然少不了身份验证,在asp.net中Form验证因该是方便的了。当然,你要是用asp.net 2.0以上的话,用MemberShip更方便。

只要简单的在web.config的<system.web>节点里加上<authentication mode="Forms" >
  <forms name="WebSite" loginUrl="login.aspx" path="/" />
</authentication>
<authorization>
    <deny users="?"/>
</authorization>
除了login.aspx其他的都有不能直接访问了。

问题也来了,css,pic也都不能访问了。

解决方法:
在刚才那个<system.web>的外面在加上<location path="img">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
这样对整个“img”目录的访问就没有限制了。

Comments

Popular posts from this blog

Python中的self

习惯上,任何Python类方法的第一个参数(对当前实例d的引用)都叫做self。这个参数扮演着C++或Java中的保留字this的角色,但self在Python中并不是一个保留字,它只是一个命名习惯。虽然如此,也请除了self之外不要使用其它的名字,这是一个非常坚固的习惯。 出自:《Dive Into Python》

Google Notebook整合了Google 书签

FF上一直装有Google笔记本的插件,一直没有到一面上去看,今天无意点到。发现多了个叫“Unfiled”的记事本,记得自己并未建过这么个东西,进去一看才发现,其实就是我的Google书签: 并且右下角也多了“Labels”,且与我Google书签中的相同。 其实人家的右上角的“ New features! ”里说得很清楚: Integration with Google Bookmarks Notebook is now integrated with Google Bookmarks. Your bookmarks will show up as a special Unfiled notebook, making Google Notebook a single place to collect and organize interesting web pages. To publish and collaborate, just drag and drop bookmarks into notebooks.