-2

I am starting a job at a new company and i'm supposed to start using a system developed in .net core MVC by someone else.

I have a local copy of the database and a local copy of the code. I can acces the SQL server DataBase and make my own SQL requests in SQL Server 2014, unfortunatly i cannot connect my Visual Studio code to my database and make everything work locally.

I tryed to load "Views\Home\Index.cshtml", the page starts to load at "localhost:45896" and after a few seconds i get the bellow error:

It appears the path is not properly written in the json file, but i am not sure how to write it any other way.

Or maybe something else.

Connection String:

"ConnectionStrings": { "DefaultConnection": "Server=/SQLExpress;Database=something_article;User Id=admins;Password=Admin;", "EntityFrameworkConnection": "data source=172.16.10.5;initial catalog=companyname_common;persist security info=True;user id=admin;password=azerty;MultipleActiveResultSets=True;App=EntityFramework"" },

Thank you

Best regards Rui

An error occurred while starting the application. Win32Exception: Le chemin d’accès spécifié n’est pas valide

Unknown location SqlException: Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: Named Pipes Provider, error: 40 - Impossible d'ouvrir une connexion à SQL Server)

System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, object providerInfo, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, string accessToken, bool applyTransientFaultHandling)

Win32Exception: Le chemin d’accès spécifié n’est pas valide

System.ComponentModel.Win32Exception (0x80004005): Le chemin d’accès spécifié n’est pas valide

SqlException: Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: Named Pipes Provider, error: 40 - Impossible d'ouvrir une connexion à SQL Server)

System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity

identity, SqlConnectionString connectionOptions, SqlCredential credential, object providerInfo, string newPassword, SecureString newSecurePassword, bool redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, string accessToken, bool applyTransientFaultHandling) System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, uint waitForMultipleObjectsTimeout, bool allowCreate, bool onlyOneCheckConnection, DbConnectionOptions userOptions, out DbConnectionInternal connection) System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource retry, DbConnectionOptions userOptions, out DbConnectionInternal connection) System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, out DbConnectionInternal connection) System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource retry, DbConnectionOptions userOptions) System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource retry) System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource retry) System.Data.SqlClient.SqlConnection.Open() Hangfire.SqlServer.SqlServerStorage.CreateAndOpenConnection() Hangfire.SqlServer.SqlServerStorage.UseConnection(DbConnection dedicatedConnection, Func func) Hangfire.SqlServer.SqlServerStorage.UseConnection(DbConnection dedicatedConnection, Action action) Hangfire.SqlServer.SqlServerStorage.Initialize() Hangfire.SqlServer.SqlServerStorage..ctor(string nameOrConnectionString, SqlServerStorageOptions options) Hangfire.SqlServerStorageExtensions.UseSqlServerStorage(IGlobalConfiguration configuration, string nameOrConnectionString, SqlServerStorageOptions options) SofedisWebsite.Startup.b__4_6(IGlobalConfiguration m) in Startup.cs

                m.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"),

new SqlServerStorageOptions()

Hangfire.HangfireServiceCollectionExtensions+<>c__DisplayClass1_0.b__10(IGlobalConfiguration config) Hangfire.HangfireServiceCollectionExtensions.GetInitializedJobStorage(IServiceProvider serviceProvider) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactoryService(FactoryService factoryService, ServiceProvider provider) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor.VisitCallSite(IServiceCallSite callSite, TArgument argument) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProvider provider) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor.VisitCallSite(IServiceCallSite callSite, TArgument argument) Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(IServiceCallSite callSite, ServiceProvider provider) Microsoft.Extensions.DependencyInjection.ServiceProvider+<>c__DisplayClass16_0.b__0(ServiceProvider provider) Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType) Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider) Hangfire.HangfireApplicationBuilderExtensions.UseHangfireServer(IApplicationBuilder app, BackgroundJobServerOptions options, IEnumerable additionalProcesses, JobStorage storage) SofedisWebsite.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime appLifetime, FileServerProvider fileServerprovider) in Startup.cs

                app.UseHangfireServer(new BackgroundJobServerOptions()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder

app) Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter+<>c__DisplayClass3_0.b__0(IApplicationBuilder app) Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.b__0(IApplicationBuilder builder) Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

.NET Framework X64 v4.0.30319.42000 |
Microsoft.AspNetCore.Hosting version 1.1.1 | Microsoft Windows 10.0.10586 | Need help?

4
  • Maybe you can take a look in your MVC application at a file called Web.config and locate the <connectionStrings> and make sure it points to your localdb?
    – mb14
    Nov 22, 2018 at 14:12
  • My web.config file has no "ConnectionString" in it. :(
    – Rui Ruivo
    Nov 22, 2018 at 14:20
  • SOLVED, how to close?
    – Rui Ruivo
    Dec 12, 2018 at 8:52
  • Post your own answer to this question and accept it Dec 12, 2018 at 11:53

2 Answers 2

0

add connection string in web config

inside configuration tag

<connectionStrings>
  <add name="connectionname" 
       connectionString="Server=localhost; Database=dbname;
       Integrated Security=True"; providerName="System.Data.SqlClient" />
</connectionStrings>

and for reading that connection string use this: -

System.Configuration.ConfigurationManager.
    ConnectionStrings["connectionname"].ConnectionString;
-1

Configure your Connection string TAG in the Web.config file.

User for example the site below:

https://www.connectionstrings.com/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.