更改主题-Web.config访问被拒绝. [英] Change Theme - Web.config Access denied.

查看:107
本文介绍了更改主题-Web.config访问被拒绝.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我需要动态更改主题

这是我的代码:

Hi Friends,

I need to change Theme dynamically

Here is my code:

Configuration config =WebConfigurationManager.OpenWebConfiguration("~");
PagesSection section =(PagesSection)config.GetSection("system.web/pages");
section.Theme = "Green";
section.StyleSheetTheme = "Green";
config.Save(); 




它可以在MS的本地服务器中运行,但是当我在LocalHost中运行时,它显示如下:




It works in Local server in MS but when I run in LocalHost it shows like this:

Access to the path 'E:\My_Work_Place\Projects - Backup\TolivaultNew\web.config' 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 path 'E:\My_Work_Place\Projects - Backup\TolivaultNew\web.config' 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.
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:

Line 173:        section.Theme = "Green";
Line 174:        section.StyleSheetTheme = "Green";
Line 175:        config.Save();



有什么办法吗? :)



Any solutions? :)

推荐答案

您需要授予您的应用程序池标识对web.config的写权限.
you need to give your application pool identity write access to web.config.


这篇关于更改主题-Web.config访问被拒绝.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆