簡體   English   中英

App中的Web.Config配置錯誤

[英]Web.Config Configuration Error in App

我已准備好將應用程序上傳到托管,但是當我在服務器上傳文件時,我收到此錯誤:

'/'應用程序中的服務器錯誤。

配置錯誤

描述:處理為此請求提供服務所需的配置文件時發生錯誤。 請查看下面的具體錯誤詳細信息並相應地修改配置文件。

分析器錯誤消息:此配置部分不能在此路徑中使用。 當站點管理員使用繼承的配置文件中的<location allowOverride =“false”>鎖定對此節的訪問權限時,會發生這種情況。

來源錯誤:

服務器上發生應用程序錯誤。 此應用程序的當前自定義錯誤設置可防止遠程查看應用程序錯誤的詳細信息(出於安全原因)。 但是,它可以由運行在本地服務器計算機上的瀏覽器查看。

托管服務台說他們無法更改服務器配置,因此我的web.config文件如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location allowOverride="true">
  <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Lampino.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

    <system.web>
      <globalization uiCulture="pl-PL" culture="pl-PL" fileEncoding="utf-8" responseEncoding="utf-8" requestEncoding="utf-8"/>
      <compilation debug="true"/>
      <customErrors mode="Off"/>
      <securityPolicy>
        <trustLevel name="Full"/>
      </securityPolicy>
    </system.web>
  </location>
</configuration>

有沒有選擇它可以在這個托管上工作或我應該找到一個新的? 也許我的web.config文件確實存在問題?

它與解決IIS問題的方式相同,但沒有任何改變。 此外,我無權訪問服務器配置...

編輯:當我刪除trustLevel標簽時收到此錯誤消息:

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: App_Web_fgajuxdi.0.cs    Line: 0 

Stack Trace: 


[SecurityException: Request failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessSecurityEngine.Check(PermissionSet permSet, StackCrawlMark& stackMark) +31
   System.Security.PermissionSet.Demand() +68
   System.Data.LocalDBAPI.DemandLocalDBPermissions() +241
   System.Data.LocalDBAPI.CreateLocalDBInstance(String instance) +32
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308411
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +262
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +434
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +225
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +37
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +321
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions) +67
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1052
   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +78
   System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +167
   System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +143
   System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +83
   System.Data.SqlClient.SqlConnection.Open() +96
   System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +316
   System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
   System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1482
   System.Web.UI.WebControls.BaseDataList.GetData() +56
   System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +173
   System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +63
   System.Web.UI.WebControls.BaseDataList.DataBind() +54
   System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +74
   System.Web.UI.WebControls.BaseDataList.CreateChildControls() +72
   System.Web.UI.Control.EnsureChildControls() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +42
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
   System.Web.UI.Page.ProcessRequest() +72
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +58
   ASP.index_aspx.ProcessRequest(HttpContext context) in App_Web_fgajuxdi.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

當前版本的ASP.NET現在只支持完全信任。您需要找到支持完全信任的托管服務提供商。 例如asphostportalhostforlife

要使用.mdf ,你需要有充分的信任級別文件(見這里的細節,在實體框架和通用Providers部分)。

您的托管服務提供商不允許您更改信任級別,因此使用<trustLevel name="Full"/>指令會導致原始錯誤。

刪除<trustLevel name="Full"/>指令解決了原始錯誤,但是由於您的Web應用程序仍需要運行完全信任級別(主機提供商不提供),因此您會收到安全性異常。

write \\ in connectionstring.

 <connectionStrings>
    <add name="ConnectionString" connectionString="Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\Lampino.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM