Static files in wwwroot is not served in ASP.NET Core 6 MVC - asp.net-core-mvc

I have files in my wwwroot folder like this:
But still, I'm getting an HTTP "404 - not found" error since the CSS files are not being served.
Even if I try to access it through localhost:
http://localhost:58233/Content/css-new
The file still causes a http 404 not found.
I did include app.UseStaticFiles(); in Program.cs, and I can see the files in the build directory:
This is weird as I assumed all files in the wwwroot folder should be served to public.
What else should I check and what am I doing wrong?

Related

Laravel App Not Loading CSS From Public Installation Not In public_html

I've installed a pre-made Laravel app and followed the documentation to extract it to the public root except in the documentation they are installing it into public_html, but I have it in a subdomain in a folder named "test" which is on the same level as public_html.
All the CSS and JS should be loading from the public subdirectory, but they try to look for it in the main root folder.
For example, this file returns a 404 error:
https://test.mydomain.com/css/style.css
The file is actually at this location:
https://test.mydomain.com/public/css/style.css
The absolute path of the file is:
/home/mydomain/test/public/css/style.css
Instead of:
/home/mydomain/public_html/public/css/style.css
What environment or config file isn't set correctly and how do I set it to use the correct directory?
UPDATE
Changing the ASSET_URL to "public" fixed the first issue, but now the same thing is happening with the admin.
The app tries to load the dashboard with this URL:
https://test.mydomain.com/admin/dashboard
The page loads all the assets normally when I remove the word "admin" from the URL:
https://test.mydomain.com/dashboard
But this doesn't work for all the pages.
You can try to put public directory path in below given conflagration file.
Config File Path : config/app.php (asset_url)
'asset_url' => env('ASSET_URL', 'https://test.mydomain.com/public/')

File Manager for TinyMCE 5 Not showing uploaded images,404 image not found,but it exists in the folder - Laravel

So,i've been having problems with integrating file manager to TinyMCE 5,uploading images into a specified folder using the file manager works without any issues,that is also true for deleting the images,but the problem is when you try to use the images,they appear as blank and if you open a console you will see error 404 messages that images don't exist
The solution that worked for me is that i went to .env file which is inside of your laravel project and then changed this line of code which is usually located in the first few lines of the file:
APP_URL=http://localhost
to this
APP_URL=http://127.0.0.1:8000
It seems like file manager uses APP_URL to build the URL for some reason,still haven't found out why tho

custom css and js files not load in laravel. How can I fix this?

css file path is---http://example.com/css/1/styles.css.
I have checked. File is already in the directory.
But not loaded.
Before it was working fine. Suddenly ALL CSS and JS file got 404 error
css file path via ftp
404 for css file

missing images and home page when moving laravel 5.2 project to live server

images works fine in localhost as src="/lr/public/bootstrap/images/photo.jpg"
but don't work on live server
error messages on live server is failed 404 not found www.mysite.com/lr/public/bootstrap/images/photo.com
note : when i remove /lr/public images works on live server
my cpanel root directory is /home/ad
in /home/ad >>
i have folder'lr' that containe my project and i deleted folder public in it
in public_html >>
i have contents of folder public >> bootstrap - uploads - index.php ..... etc
Looks like you didn't link your images correctly.
I believe the link should be:
www.mysite.com/bootstrap/images/photo.jpg
not:
www.mysite.com/lr/public/bootstrap/images/photo.com
Use: asset('bootstrap/images/photo.jpg') for linking files from your public folder.
Blade example. <img src="{{ asset('bootstrap/images/photo.jpg') }}">
Make sure 'photo.jpg' exists in 'public/bootstrap/images/' directory

How to open a pdf file which is in views or controller folder in ci?

i have a pdf file in view folder and controller folder by the link i need to access it how to do this i have tried with following by am getting error like
Access forbidden!
$path=base_url()."application/views/users/sample_pdf_report.pdf";
$path2="C:\xampp\htdocs\vacationgod\application\views\users\sample_pdf_report.pdf"
// OPTIONAL - PUT A LINK TO DOWNLOAD THE PDF YOU JUST CREATED
echo ("<a href='$path2'>Download Your PDF</a>");
i have tried both $path and $path2
You probably have a .htaccess file forbidding people to access files in those folders.
You should create a res folder in your site root path and place your pdf file in that folder and link the file from there..
Happy coding :)

Resources