simple question on Views

elsvieta 371 Reputation points
2023-12-07T18:40:22.73+00:00

hi all,

I have a sample project (NET 8, ASP.NET Core MVC) and I added a few Controllers and Views.

Controllers: Home Controller, Group1Controller, Group2Controller

Views: Home folder: Index.cshtml, Privacy.cshtml
Group1 folder: Index.cshtml
Group2 folder: Index.cshtml

Models folder:
BaseViewModel.cs
ErrorViewModel.cs

and Program.cs directly under the project folder

Without entering any other details is it possible to know what I am missing knowing that I can
navigate to https://localhost:7114 and https://localhost:7114/Group2 and https://localhost:7114/Group2/Index and
https://localhost:7114/Group2/Index/2 or https://localhost:7114/Group2/Index/3 or any other id just by typing these paths, however I can see a logo only when I go to https://localhost:7114/Group2

The Index.cshtml in the Group2 folder does have the line:

<td style="width: 200px; height: 100px" rowspan="4"><img src="images/MyLogo2.png" alt="My Logo" /></td>

I believe https://localhost:7114/Group2 and https://localhost:7114/Group2/Index and https://localhost:7114/Group2/Index/2 they all display the Index.cshtml in the Group2 folder. Yet only https://localhost:7114/Group2 will display the logo, all other urls are missing the logo (and only the logo).

Can you please let me know what am I missing?

thanks,

elsvieta

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2023-12-07T18:57:15.35+00:00

    Try a relative path.

    <img src="/images/MyLogo2.png" alt="My Logo" />
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-12-07T20:16:56.6933333+00:00

    If you used the browsers debug tools, you would have seen the found error, and the bad path.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.