MVC3網站的管理部分創建爲區域。然後我把下面的代碼在Web.config防止訪問.Net MVC中的特定區域
<location path="Admin">
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Admin/Login/Login" timeout="5000" defaultUrl="~/Admin/Login/Redirect" />
</authentication>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
然而,它拋出一個錯誤
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
源錯誤:
Line 44: <location path="Admin">
Line 45: <system.web>
Line 46: <authentication mode="Forms">
Line 47: <forms loginUrl="~/Admin/Login/Login" timeout="5000" defaultUrl="~/Admin/Login/Redirect" />
Line 48: </authentication>
我只需要密碼保護區域的管理目錄。我應該如何繼續。請指導。 – Ajoe 2013-03-13 07:31:07
您可以編寫自定義授權屬性。根據你想存儲用戶數據的位置,你也可以啓用['Basic Authentication'](http://en.wikipedia.org/wiki/Basic_access_authentication)。 – 2013-03-13 07:31:50