I am sorry, Walter, but the web app *is* writing to this config file. I built
a series of admin web pages that let users change config settings. Sorry if I
wasn't clear on this.
To rephrase the question: How can a web app in Medium Trust save changes to
one of its own config files that are being managed using the .NET 2.0
Configuration API? The config file is within the web app directory.
-Roger
Hi Roger,
I somehow overlooked the requirement is to "save" instead of "read-only",
sorry.
I just re-checked the document and confirmed that
WebConfigurationManager.OpenWebConfiguration requires Full Trust.
I'll do some further researching and consulting to see if there's other
solution to this issue other than creating a separate assembly and install
into GAC to give it Full Trust.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 22 Aug 2007 04:45 GMT
Hi Roger,
Sorry for late reply. I've been consulting your question within our
internal discussion list.
Unfortunately there's no other good way to edit web site's web.config under
medium trust. Currently the OpenWebConfiguration will always require full
trust to run; and we have to use it to get a reference to the configuration
items. Sorry for the inconvenience caused.
If you don't want to create a separate assembly and give it full trust or
create a custom policy, then you might have to fallback to plain xml
document processing to edit the web configuration.
#How To: Use Medium Trust in ASP.NET 2.0
http://msdn2.microsoft.com/en-us/library/ms998341.aspx
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Roger Martin - 23 Aug 2007 22:58 GMT
Any word on this, Walter? This is the last major issue preventing my app from
working in medium trust.
Roger
Walter Wang [MSFT] - 27 Aug 2007 07:19 GMT
Hi Roger,
Since the web site's web.config is actually inheriting some settings from
machine.config (or its parent folder's web.config, if there's any), the
WebConfigurationManager API will have to be able to access them to provide
full object model of the settings. Therefore I'm afraid there's no other
way to workaround this.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Roger Martin - 27 Aug 2007 14:08 GMT
Thanks for getting to the bottom of this, Walter. The inability to save
settings using the Configuration API in medium trust certainly takes all the
fun out of the API. I'll cross my fingers that .NET 3.5 addresses this issue.
Cheers,
Roger Martin
Walter Wang [MSFT] - 28 Aug 2007 06:47 GMT
Hi Roger,
Thanks for your quick reply.
I agree this is a limitation of the Configuration API. Your feedback is
recorded and will be correctly forwarded to product team.
Please let me know if there's anything else I can help.
Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.