asp.Net 回发安全错误
我的 Web 应用程序出现了一个非常奇怪的错误:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request failed.
Source Error:
[No relevant source lines]
Source File: c:\windows\Microsoft.NET\Framework\v4.0.21006\Temporary ASP.NET Files\root\9d105d0f\5a29f9f\App_Web_w324g3dv.1.cs Line: 0
Stack Trace:
[SecurityException: Request failed.]
AjaxControlToolkit.HTMLEditor.EditPanel.set_ActiveMode(ActiveModeType value) in C:\Users\Machta\Documents\Visual Studio 10\Projects\AjaxControlToolkit_9c860ac12ae9\Server\AjaxControlToolkit\HTMLEditor\EditPanel.cs:400
AjaxControlToolkit.HTMLEditor.EditPanel.LoadPostData(String postDataKey, NameValueCollection postCollection) in C:\Users\Machta\Documents\Visual Studio 10\Projects\AjaxControlToolkit_9c860ac12ae9\Server\AjaxControlToolkit\HTMLEditor\EditPanel.cs:142
AjaxControlToolkit.ScriptControlBase.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) in C:\Users\Machta\Documents\Visual Studio 10\Projects\AjaxControlToolkit_9c860ac12ae9\Server\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:426
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +8766531
...
仅当我将其发布到服务器上时才会发生(这很好,只要它是安全异常)。
奇怪的是,该应用程序需要访问本应位于我计算机上的文件夹中的文件的权限。但我的电脑上不存在这个文件夹。当我重新安装 Visual Studio 时,我还将项目移动到另一个文件夹(名称相似,但仍然是不同的文件夹)。
所以我的问题是:
- 为什么应用程序需要我计算机上的文件,而文件位于服务器上?
- 为什么它在我的计算机上工作,而文件也不应该在这里?
- 可能的原因和解决方案是什么?
您可以在这里尝试:http://machta.aspone.cz/editor/webConntentEditor.aspx。 用户名:machta 密码:123456
我还应该补充一点,每次回发后都会出现此错误,但页面加载正常。
My web application presents a very strange error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request failed.
Source Error:
[No relevant source lines]
Source File: c:\windows\Microsoft.NET\Framework\v4.0.21006\Temporary ASP.NET Files\root\9d105d0f\5a29f9f\App_Web_w324g3dv.1.cs Line: 0
Stack Trace:
[SecurityException: Request failed.]
AjaxControlToolkit.HTMLEditor.EditPanel.set_ActiveMode(ActiveModeType value) in C:\Users\Machta\Documents\Visual Studio 10\Projects\AjaxControlToolkit_9c860ac12ae9\Server\AjaxControlToolkit\HTMLEditor\EditPanel.cs:400
AjaxControlToolkit.HTMLEditor.EditPanel.LoadPostData(String postDataKey, NameValueCollection postCollection) in C:\Users\Machta\Documents\Visual Studio 10\Projects\AjaxControlToolkit_9c860ac12ae9\Server\AjaxControlToolkit\HTMLEditor\EditPanel.cs:142
AjaxControlToolkit.ScriptControlBase.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) in C:\Users\Machta\Documents\Visual Studio 10\Projects\AjaxControlToolkit_9c860ac12ae9\Server\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:426
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +8766531
...
It occurs only when I publish it on the server (which is fine, provided it's a security exception).
What is strange about it is that the application requires a permission to access a file that is supposed to be located in a folder on my computer. But this folder doesn't exist on my computer. When I reinstalled Visual Studio I also moved the project to a different folder (with similar name but it's still a different folder).
So my questions are:
- Why the application needs the file on my computer when its on the server?
- And why it works on my computer when the file shouldn't be here either?
- What can be the possible causes and solutions?
You can try it here: http://machta.aspone.cz/editor/webConntentEditor.aspx.
User name: machta password:123456
I should also add that this error appears after every postback but the page loads fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许默认情况下您的服务器的信任级别已降低。
尝试将以下行添加到您的 web.config
来源
Maybe the trust-level of your server is lowered by default.
Try to add the following lines to your web.config
Source
首先,它并不请求您计算机上的文件。它只是告诉您已编译的文件的名称(和位置)以及失败的相关代码行。
PDB 在编译应用程序时存储此信息,这就是引用硬盘上某个位置的原因。
如果引用的位置不再有效,那么听起来自从您移动本地源以来,您还没有将整个应用程序部署到服务器。
综上所述,第 400 行或您的 EditPanel 是做什么的?如果它尝试将文件写入 Web 服务器上的某个位置,那么您需要确保正在执行该应用程序的用户具有写入权限来执行此操作。提示:查看应用程序池设置。
First off, it's not requesting a file on your computer. It's just telling you the name of the file (and location) that was compiled and the relevant line of code that failed.
The PDB's store this information at the time the application is compiled which is why the reference is to a location on your harddrive.
If that referenced location is no longer valid then it sounds like you haven't deployed the whole app to the server since you moved your local source.
All of that said, what does line 400 or your EditPanel do? If it's trying to write a file to a location on the web server then you need to make sure that the user the app is executing under has writes to do this. hint: look at the application pool settings.