Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当我的ASP.Net网站不允许执行由web托管服务的安全策略定义的某些操作时,我该怎么办?_C#_Asp.net - Fatal编程技术网

C# 当我的ASP.Net网站不允许执行由web托管服务的安全策略定义的某些操作时,我该怎么办?

C# 当我的ASP.Net网站不允许执行由web托管服务的安全策略定义的某些操作时,我该怎么办?,c#,asp.net,C#,Asp.net,我的asp.net站点代码为C,在本地系统上运行良好,但当我通过plesk将文件上载到httpdocs文件夹时,我发现以下错误: Server Error in '/' Application. ________________________________________ Compilation Error Description: An error occurred during the compilation of a resource required to service this

我的asp.net站点代码为C,在本地系统上运行良好,但当我通过plesk将文件上载到httpdocs文件夹时,我发现以下错误:

Server Error in '/' Application.
________________________________________
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0246: The type or namespace name 'Xyz' could not be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 1:  <%@ Application Language="C#" %>
Line 2:  <%@ Import Namespace="xyz" %>
Line 3:  <%@ Import Namespace="System.Web.Optimization" %>
Line 4:  <%@ Import Namespace="System.Web.Routing" %>

Source File: g:\PleskVhosts\xyz.com\httpdocs\Xyz\Global.asax    Line: 2 

Show Detailed Compiler Output:


C:\Windows\SysWOW64\inetsrv> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ba70df64\8ad7fdd9\App_global.asax.8gpjfmvi.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701;612;618 /warnaserror-  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ba70df64\8ad7fdd9\App_global.asax.8gpjfmvi.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ba70df64\8ad7fdd9\App_global.asax.8gpjfmvi.1.cs"


Microsoft (R) Visual C# Compiler version 4.0.30319.17929

for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

g:\PleskVhosts\xyz.com\httpdocs\Xyz\Global.asax(2,11): error CS0246: The type or namespace name 'Xyz' could not be found (are you missing a using directive or an assembly reference?)
g:\PleskVhosts\xyz.com\httpdocs\Xyz\Global.asax(3,22): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
g:\PleskVhosts\xyz.com\httpdocs\Xyz\Web.config(24,21): error CS0234: The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)


________________________________________
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18056

您需要右键单击项目,然后选择“发布”。您可以发布到文件系统,以便在上载到godaddy之前更改Web.config,也可以将其设置为发布到godaddy站点。我会选择文件系统方法。一步一个脚印


正如您在评论中所说,除了项目文件夹中的解决方案文件之外,我添加了所有文件和文件夹,这没有任何作用。要从中执行,它需要在VisualStudioIDE中运行。要正确设置所有文件应用于生产的位置,您必须发布web项目。

您发布的新错误肯定与安全相关。
转到“网站和域”选项卡。在帐户的主域下,单击图标ASP.NET设置。加载页面时,您应该能够在“代码访问安全”下将权限设置为“完全”。试一试,让我们知道这是否能解决GoDaddy的安全/权限问题,登录到你的GoDaddy Windows Plesk帐户并展开Web Hosting选项卡。然后,单击启动按钮访问网站和域控制面板。从那里找到您当前正在处理的网站、域或子域。单击ASP.NET设置按钮,将CAS信任级别调整为Full,将默认网页语言调整为C。在那里,您还可以输入并保存连接字符串、身份验证模式、ASP.NET版本等。

如果遇到相同的问题,可以使用web.config修复错误。将level=Full-level添加到trust元素中,如下所示:

<system.web>
   ...
   <trust level="Full" />
   ...
</system.web>

除了前面的评论,我注意到GoDaddy同时使用MVC和WebForms应用程序的一点是,GoDaddy讨厌Roslyn。这是使用Visual Studio中的新应用程序的默认编译器。除了将CAS设置为完全访问之外,请确保从项目中删除Microsoft.Net.Compilers包及其依赖项,在发布之前使用“发布设置”中的复选框删除所有现有文件-不要实际删除帐户中的所有内容!你应该可以走了。每次GoDaddy从Visual Studio发布应用程序时,我都会遇到这个问题


祝找到这个的人好运

GoDaddy没有什么不好的地方——在我的机器上工作是一个众所周知的问题,因为程序员没有考虑需要什么。那么,名称空间Xyz包含什么?你引用它,所以-它必须存在。你上传了所有文件和文件夹吗?当我在中创建项目时,所有文件都保存在C:\User\Mydocuments\VisualStudio2013\Websites\xyz\中。我在项目文件夹中添加了除解决方案文件外的所有文件和文件夹。我投票关闭这个问题,因为这应该指向Godaddy客户支持您好,非常感谢,我这样做了,但我遇到了一个错误,在我看来,web.config文件必须做一些更改。此外,我还将设置更改为ASP.net版本4。由于4.5不可用,我的网站是在.net 4.5中构建的。将语言更改为C3。我的代码在C中验证设置为无,自定义错误设置为关闭。错误是这样的错误是在新的错误行之后添加到原始帖子中的错误非常感谢您的帮助我不确定抛出的异常是指什么。可能正在尝试连接到您的数据存储,可能没有。但是,由于这是一个与您的原始问题(仅复制项目文件结构而不是发布)无关的错误,因此这个新的错误消息应该是它自己的问题。在你发布它之前,我会尝试添加一些异常捕捉,看看你是否能找到它发生的地方,这样人们就有更好的机会帮助你。
<system.web>
   ...
   <trust level="Full" />
   ...
</system.web>