I made my simple project that save my ideas to "(localdb)\mssqllocaldb"
.
namespace publish.Models
{
public class idea
{
public int Id { get; set; }
public string Name { get; set; }
}
}
I use asp.net.core 6.0 - mvc. I published this project to local folder and deploy using iis manager. However after publishing, I tried browse but failed. Because it is failed to connect local database. How can I resolve this problem?
I saw lecture the name is "How to Publish an ASP .NET Core 6 Website _ APP on a Windows OS and Fix Database Connection Problem". I tried to resolve using this method. From "Microsoft Sql Server management studio", I create new login as sql server authentication. Then change the connection string in appsetting.json like that
"ConnectionStrings": {
"publishContext": "Server=(localdb)\\mssqllocaldb;Database=publish.Data;uid=ali12;pwd=123;"
}
And published using this connectionstrings. However, I saw error message like this
Error.
An error occurred while processing your request. Request ID: 00-e7f938a225da4cf8d5148cfd354c0f34-01a9fa13f2a60d36-00 ...
=============================================== Dear Jason Pan, I tried to resolve my problem from your guidance. However, I didn`t success.
I also using localdb and facing the same issue. You can add below code in web.config file, then you will get more detailed error message.
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
My sample web.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\AspCore7_Web_Identity.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: E938A144-170E-4E89-****-9B88****7039-->
And get below error message.
Solution
You need to install the Microsoft SQL Server in your server and make sure it can be accessed.