C# 使用TempData建立与SQL Server的连接时发生网络相关或特定于实例的错误
我正在尝试在控制器中使用C# 使用TempData建立与SQL Server的连接时发生网络相关或特定于实例的错误,c#,sql-server,model-view-controller,C#,Sql Server,Model View Controller,我正在尝试在控制器中使用TempData,以便在请求之间保存从下拉列表中选择的值,但这不起作用。只有在添加TempData代码时才会出现此错误,因此SaveProcessView和ProcessViewForAdmin方法在没有TempData代码的情况下可以正常工作 我一直在网上搜索答案,但我似乎找不到任何答案,但它似乎找不到我的SQL Server,这很奇怪,因为网站上其他地方的数据库工作正常。允许远程连接 我得到以下错误: 建立与SQL Server的连接时发生与网络相关或特定于实例的错误
TempData
,以便在请求之间保存从下拉列表中选择的值,但这不起作用。只有在添加TempData代码时才会出现此错误,因此SaveProcessView
和ProcessViewForAdmin
方法在没有TempData代码的情况下可以正常工作
我一直在网上搜索答案,但我似乎找不到任何答案,但它似乎找不到我的SQL Server,这很奇怪,因为网站上其他地方的数据库工作正常。允许远程连接
我得到以下错误:
建立与SQL Server的连接时发生与网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:26-定位指定的服务器/实例时出错)描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源 异常详细信息:System.Data.SqlClient.SqlException:建立到SQL Server的连接时发生网络相关或特定于实例的错误。找不到服务器或无法访问服务器。验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:26-定位指定的服务器/实例时出错) 源错误: 在执行当前web请求期间生成了未经处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来识别 [SqlException(0x80131904):建立与SQL Server的连接时发生网络相关或特定于实例的错误。找不到或无法访问该服务器。请验证实例名称是否正确,以及SQL Server是否配置为允许远程连接。(提供程序:SQL网络接口,错误:26-定位指定的服务器/实例时出错)] System.Data.SqlClient.SqlInternalConnection.OneError(SqlException异常,布尔断开连接,操作'1 wrapCloseInAction)+5352431 System.Data.SqlClient.TdsParser.ThroweException和Warning(TdsParserStateObject stateObj,布尔调用者连接锁,布尔异步关闭)+244
System.Data.SqlClient.TdsParser.Connect(ServerInfo ServerInfo,sqlinternalconnectionds connHandler,Boolean ignoresnopentimeout,Int64 timerExpire,Boolean encrypt,Boolean trustServerCert,Boolean integratedSecurity,Boolean with failover)+5363103
System.Data.SqlClient.SqlInternalConnectionDS.AttemptOneLogin(ServerInfo ServerInfo、String newPassword、SecureString newSecurePassword、Boolean IgnoresInOpenTimeout、TimeoutTimer timeout、Boolean withFailover)+145
System.Data.SqlClient.SqlInternalConnectionDs.LoginOfAliver(ServerInfo服务器信息、字符串newPassword、SecureString newSecurePassword、Boolean redirectedUserInstance、SqlConnectionString连接选项、SqlCredential凭证、超时)+922
System.Data.SqlClient.SqlInternalConnectionDS.OpenLoginList(超时超时、SqlConnectionString连接选项、SqlCredential凭证、String新密码、SecureString newSecurePassword、Boolean redirectedUserInstance)+307
System.Data.SqlClient.SqlInternalConnectionDS..ctor(DbConnectionPoolIdentity、SqlConnectionString connectionOptions、SqlCredential凭证、对象提供者信息、String newPassword、SecureString newSecurePassword、Boolean redirectedUserInstance、SqlConnectionString userConnectionOptions、SessionData reconnectSessionData)+518
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions选项、DbConnectionPoolKey poolKey、Object poolGroupProviderInfo、DbConnectionPool池、DbConnectionOwningConnection、DbConnectionOptions用户选项)+278
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool池、DbConnectionOwningObject、DbConnectionOptions选项、DbConnectionPoolKey池键、DbConnectionOptions用户选项)+38
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection-owningObject、DbConnectionOptions-userOptions、DbConnectionInternal-oldConnection)+732
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject、DbConnectionOptions userOptions、DbConnectionInternal oldConnection)+85
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection-owningObject,UInt32-WaitForMultipleObjectsStimOut,布尔allowCreate,布尔OnlyOnEckConnection,DbConnectionOptions-userOptions,DbConnectionInternal&connection)+1057
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject、TaskCompletionSource
1重试、DbConnectionOptions用户选项、DbConnectionInternal和connection)+78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection所有者连接、TaskCompletionSource
1重试、DbConnectionOptions用户选项、DbConnectionInternal oldConnection、DbConnectionInternal和connection)+196System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource
1重试,DbConnectionOptions用户选项)+146
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory,TaskCompletionSource
1重试,DbConnectionOptions用户选项)+16System.Data.SqlClient.SqlConnection.tryopeniner(TaskCompletionSource
1重试)+94
系统
public ActionResult ProcessViewForAdmin()
{
var model = _IGenerateProcessFlowData.UpdateProcessFlowViewModel();
var modeltemp = TempData["model"] as ProcessViewModel;
if (modeltemp != null)
{
model.SelectedCustomer = modeltemp.SelectedCustomer;
model.SelectedSeconds = modeltemp.SelectedSeconds;
}
return View(model);
}
[HttpPost]
public ActionResult SaveProcessViewForCustomer(ProcessViewModel model)
{
TempData["model"] = model;
_iSlideLogic.ConnectProcessViewAndSlideByMainCustomerName(model.SelectedCustomer, 1, "", model.SelectedSeconds);
return RedirectToAction("ProcessViewForAdmin");
}
<add name="DBEntities"
connectionString="metadata=res://*/Context.Overvakning.csdl|res://*/Context.Overvakning.ssdl|res://*/Context.Overvakning.msl;provider=System.Data.SqlClient;provider connection string="data source=Ah-XXXXXXXXX.se;initial catalog=ah-XXXXXXXX;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
Cannot open database "ASPState" requested by the login. The login failed.
Login failed for user 'XXXXXX'.