skip to Main Content

I have two projects for the API and UI side of my project.
On the UI side, I want to see the change I made with "ctrl + shift + w" on index.cshtml, but I get the error in the screenshot below.

There are errors I receive on the visual studio side and in the microsoft visual studio debug console.
Can you help me please?

visual studio

visual studio debug console

Sometimes I get errors like the one below.

visual studio

According to my research, I deleted launchsettings.json in the Properties folder of the UI project and added it again, but it did not work.

When I came to the debug properties of the project, I examined the http, https and IIS sections. Here, in the https section, these addresses were written as https://localhost:7069;http://localhost:5007.

For testing purposes, I opened the IIS side and copied the localhost address there and pasted it into the https section. It worked this time, but I still viewed the swagger page. This was not the page I wanted. Below is the screenshot.

Debug Properties
Continue from the page

Also, there is no place where I can open the properties of the project and enable or disable SSL. So that option is not possible either. Maybe it’s not visible because I’m missing something, I’m not sure.

I want to see the change I made with Browser View.
None of http, https or IIS are working during the run phase. I don’t know whether it’s a problem with localhost or the certificate.


The solutions I tried are:

dotnet dev-certs https –clean
dotnet dev-certs https –trust

Uninstall IIS Express via Add Remove Program
Run command: dotnet dev-certs https –clean
Re-install IIS Express by downloading it from the Microsoft website
Run the Asp.Net application from Visual Studio
Visual studio will prompt for generating a certificate, click yes. In my case, it generated the certificate but failed to add the certificate to the trusted root with an error ‘Access Denied’
Windows + R and type mmc
File > Add Snap-In
Select Certificates and click add
Select the ‘Computer account’ option and click finish, then click Ok.
Then expand the certificates(Local Computer) > Personal > Certificates
You will find a local host certificate with the friendly name ‘ISS Express Development Certificate’
Select the certificate then cut and paste it into Trusted Root Certification Authorities -> Certificates

Below are the screenshots that I would like to show additionally.

Personal Certificate
 Trusted Root Certification Authorities

Project File Screenshot
Project Files

Code Blocks

RealEstate_Dapper_UI / Properties / launchSettings.json

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:29591",
      "sslPort": 44379
    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "http://localhost:5112",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7240;http://localhost:5112",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

The index.cshtml I want to run:

@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_MemberLayout.cshtml";
}

<h1>Index</h1>

UI project/ Program.cs

    var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

RealEstate_Dapper_Api / Properties / launchSettings.json

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:21668",
      "sslPort": 44323
    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "http://localhost:5027",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:7032;http://localhost:5027",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

Debug Properties Menu Screenshots

  1. https properties
  2. IIS Properties
  3. http properties

2

Answers


  1. Chosen as BEST ANSWER

    Finally I was able to solve the problem. Let me try to write down the steps I followed. Since I tried so many methods, I don't know which one is the final solution.

    First of all, I only performed steps 2 and 3 of the steps in this blog.

    After doing this, I completely removed the Visual Studio 2022 Preview version from the computer. I installed the non-preview version. In the installation step, I added all the installations that I thought might be related to IIS and SSL. I rechecked all sdks like .net 7, .net 8 sdk. I installed the hosting bundle. After following many methods one after another, localhost started to open in the same project.


  2. If you delete the property folder and the hidden .vs folder. Open the solution again, the launching port will be reset a new one and without swagger.
    enter image description here
    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search