1

I just created a WebPage in Blazor I used the template "Individual Account" in the beginning of the creation of this project the purpose to create this WebPage is just to Authenticate with Windows. The WebPage works fine in my computer and is authenticated in Windows without problem, I didn't use anything with SQL but it looks that the Template has some connection but anyway the WebPage is working fine in my local computer.

The problem is when the WebPage is published in the Server in IIS when the "Microsoft" button is clicked and the user and password are specified:

The Microsoft button to Authenticate with Microsoft Windows

After hit the "Microsoft" button and specify user/passw in IIS or actually with another computer in the network I get the following error:

This is the error with Development Mode from IIS published

I thought that was necessary install the SQL Express in the Server where is published but after install SQL Express the same error still.

This is the information inside appsetting.json that was created automatically with the template and as I mentioned it works OK in my computer:

appsetting.json description

If I verify in Blazor the SQL Server Object Explorer this is what it looks:

SQL Server Object Explorer

I didn't modify nothing in appsetting.json, it looks like I need to specify the Connection from the SQL Express from the server but I don't know what values should I specify.

I'm not using any SQL Data Base or SQL, the connections came from the Initial template used when the project was created.

If I change the "DefaultConnection" values in my local computer were the project is working fine then I get the same error like the IIS published webpage so it looks that the "DefaultConnection" should have information from the IIS server and not from my local computer.

As I mentioned I didn't use any SQL DataBase in my code I just leave the SQL connection created by default when I specify the template "Individual Account" in Blazor.

Looking the Server Configuration Manager in the IIS Server after install SQL Express:

Server Configuration Manager in the IIS Server

So I found an example with SQLExpress used in "DefaultConnection":

appsettings.json

And I get the following different error:

Error

Is there something else I need to install in the IIS Server?

Why if I Published the project is not including the SQL DB and connection? Or what else I need to do in the IIS Server?

Or should I change something in the appsetting.json?

It looks like I just need to specify the correct information in "DefaultConnection" pointing to the right information to IIS Server but I don't know what information specify in appsetting.json.

Thank you!!!

1
  • Where is the Database located (local or remote)? You need to change the server name in the connection string (and or instance) in the json file : Server::(localdb)\\mssqllocaldb. The connection string indicates the database is local on the server. I would change the Server name (localdb) to the Machine name on the machine that is working. Like Server::MyClientMachine\\mssqllocaldb. Or you need to create a SQL Server and Database on any machine on the Network (could be the server you are using or any server). Commented Jan 22 at 21:03

1 Answer 1

0
  • First i would like to suggest you to install sql server on your machine.

https://www.microsoft.com/en-us/sql-server/sql-server-downloads

To manage SQL server database you need to install the SSMS:

https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16

You need the sql server as by default individual authentication template is configured to use Entity Framework Core with a local database.

  • So after you install sql server specify the local server database connection string in the appsettings.json file.

    "DefaultConnection": "Server=servername;Database=dbname;Trust Server Certificate=True;Trusted_Connection=True;MultipleActiveResultSets=true"

  • After that run below command to migrate and update database to new server:

    Add-Migration InitialCreate

    Update-Database

  • Republish the application.

  • On the iis server set the application pool identity to the desired user account that can access the sql server database.(you can use windows user administrator account)

enter image description here

Now you can access the site without any issue

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.