Reputation: 1731
First of all, I'm using Chrome browser for development.
I have placed the files in the following order:
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:
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).
Upvotes: 0
Views: 9554
Reputation: 1731
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.
Upvotes: 2
Reputation: 2429
App_Data is not typically used to publish web content, and is not published by default.
Upvotes: 2
Reputation: 2166
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.
Upvotes: 0
Reputation: 8628
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.
Upvotes: 2
Reputation: 628
Try relative path as below, it might help you-
<link href="../css/bootstrap.min.css" rel="stylesheet" />
Upvotes: 0