2010-12-03 32 views
3

我已閱讀其他職位關於如何做到這一點,但無濟於事。當我部署我的應用程序服務器(2008年)我得到以下異常在運行時:如何將我的ASP.NET MVC應用程序讀取權限授予註冊表項?

Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers' is denied. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.UnauthorizedAccessException: Access to the registry key 'HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\TeamFoundation\Servers' is denied. 

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. 

授予ASP.NET對文件的訪問,請右鍵單擊資源管理器中,選擇「屬性」,然後選擇安全選項卡。點擊「添加」添加適當的用戶或組。突出顯示ASP.NET帳戶,然後選中所需訪問權限的複選框。

所以這個錯誤看起來很具描述性。我打開註冊表編輯器並右鍵單擊KEY(HKEY_CURRENT_USER \ Software \ Microsoft) - > Permissions - >添加用戶'NETWORK SERIVCE'並授予完全控制權。

我認爲這是ASP.NET運行以訪問註冊表的用戶。

然後我試圖禁用'包含此對象的父對象的可繼承權限。

這也沒有工作。

從IIS管理器中,在我的應用程序的身份驗證設置下,我將「匿名身份驗證」用戶設置爲管理員組中的我自己的用戶。

似乎沒有任何工作。

我該如何解決這個問題?這是一個在我們的本地網絡上運行的內部工具,所以在這個階段我不太關心安全權限。我怎樣才能授予適當的權限?

謝謝!

+0

如果您將匿名用戶設置爲除NETWORK SERVICE以外的其他用戶,則應該授予該用戶對註冊表的訪問權限。 – casperOne 2010-12-03 21:08:13

回答

1

如果不知道您的Web應用程序正在嘗試完成什麼,則很難排除故障。但是,我認爲這是一個基於Web的應用程序,這意味着您已爲您的Web創建了一個數據庫。首先,在您的Web.config'connectionString'中,嘗試使用您用來登錄到SQL Server Management的用戶名和密碼。不要使用Windows登錄。其次,嘗試使用F5功能鍵運行您的應用程序。這將啓動Visual Studio 2008附帶的內置服務器。這不需要本地IIS。

如果仍然有問題,請發送或發送您的Web.config。看看我能不能幫忙。

1

我必須爲此應用程序將「應用程序池標識」設置爲「LocalSystem」。這使我的應用程序有足夠的權限來讀取註冊表。

相關問題