0

First of all, I'm using Chrome browser for development.

I have placed the files in the following order:

enter image description here

In Markup, I placed its reference like this:

<link href="App_Data/css/bootstrap.min.css" rel="stylesheet" />

This is the original path: root/App_Data/css/bootstrap.min.css.

The file is available at the path, but still, the browser can't find the file with an error shown in the picture below:

enter image description here

I am confused. Why is it not able to find the file from the correct path? :S What mistake am I making? (My previous question was also about the path. I tried following my last question's guide, but that also is not resolving this issue. Please look into it and tell me the possible issues. Thank you).

j08691
  • 204,283
  • 31
  • 260
  • 272
ARr0w
  • 1,701
  • 15
  • 31

5 Answers5

2

I'm sure App_Data is a special folder in MVC, consider moving the files in to a "content" folder or something (as is the standard).

Also try prefixes like "./" or "/" or "../" as depending on the url of the current page you may want to have a different path for these resources or always generate one that's relative from the root of the site.

War
  • 8,539
  • 4
  • 46
  • 98
2

I've just found a solution with the help of someone who commented here but deleted the comment. He was correct! I couldn't see his nickname. I'd prefer him to answer, i'll Tick his answer.

APP_data folder in asp.net doesn't let browser load Css and JS files as this folder is standard for Class files e.g. ( abc.cs ) .

I just moved all of these files in a new folder i created with the name Content and moved all css and js files in it, referenced it in Html and it worked like a charm.

ARr0w
  • 1,701
  • 15
  • 31
2

App_Data is not typically used to publish web content, and is not published by default.

Community
  • 1
  • 1
Beofett
  • 2,388
  • 1
  • 23
  • 37
  • No problem, glad I could help! Feels like a pretty sparse answer, but it sounds like it got you pointed in the right direction :) – Beofett May 16 '17 at 14:06
0

Try relative path as below, it might help you-

<link href="../css/bootstrap.min.css" rel="stylesheet" />
Chirag Jain
  • 628
  • 11
  • 24
0

You have to start with the root of your application.App_Data is just a folder in Microsoft Visual Studio context.Once you publish your app it will not be the same. For your question, this would be the solution:

<link href="/css/bootstrap.min.css" rel="stylesheet" /> 

This will resolve the path from the app root.

Nesan Mano
  • 1,892
  • 2
  • 26
  • 43