Relative and absolute path problems in .net core app when published - asp.net-core

I have got this problem with a program when I publish it to the server, the problem arises because it is published to a folder on the server rather than the root.
In the pages there are bits of code like this in the .cshtml files
#section head {
<link rel="stylesheet" href="/css/login.scss" />
}
If I publish this it interprets it as the file being at www.website.com/css/login.scss instead of www.website.com/folder/css/login.scss
I tried to use ~ infront of the link but that causes the whole program to crash with an Error 500, logging says this:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM3MGHFA29RH", Request id "0HM3MGHFA29RH:00000001": An unhandled exception was thrown by the application.
System.IO.FileNotFoundException: No files found matching "/folder/css/login.scss" exist in "C:\inetpub\wwwroot\website\folder\wwwroot\"
Adding the ~ makes the program think the file is in the wrong location, I don't know how to resolve this without publishing the project to a root of a website which I want to avoid. I've tried all kinds of methods but am getting nowhere.

Related

Vue 3 browser caching doesnt pick latest files

We have a build.js code in our project which makes a duplicate of our client directory and adds a folder inside src.
example -
client/src/components will become dist/src/abcxy/components
abcxy will change every time we create a new build.
Now the problem is that the browser tries to find the old dist files from the cache and is unable to find them, instead of finding new files it gives an error in the console.
The error changes depending on the browser I am using
EXAMPLE ERROR - Failed to load ‘http://localhost/src/pbtsg/components/report/reports.js’. A ServiceWorker intercepted the request and encountered an unexpected error.

Adobe analytics with vue js adding external script

Im struggling to add adobe analytics external scripts to my Vue js project. The client uses Adobe analytics and im battling to add it to the project without the project complaining.
The external adobe script looks like the following:
//assets.adobedtm.com/file.min.js with async
Then it is required that you end it by adding the following just before the closing body tag:
<script type="text/javascript">_satellite.pageBottom();</script>
When the project starts it complains in console that $ is not defined because it is defined in webpack when i start the project and im guessing its not finding the alias.
This is the error:
VM29714:3 Uncaught ReferenceError: $ is not defined
Then further down it complains that it doesnt know what _satellite is:
login:54 Uncaught ReferenceError: _satellite is not defined
I just need the scripts and satellite close to be added to the project, the rest will work once these are added.
Ive tried added the scripts by injecting them into the head tag on runtime but that also doesnt work.
If you are implementing Adobe DTM, you cannot inject the header script dynamically. It must be placed directly on the page without async or deferred attributes.
If you are implementing Adobe Launch, you can inject the header script dynamically and asynchronously. And if you do this, you do not include the footer (_satellite.pageBottom()) code.
Your script example isn't explicit, but the .min portion implies you are using Adobe Launch.
VM29714:3 Uncaught ReferenceError: $ is not defined
This is not directly related to either Adobe DTM or Launch. You may possibly have some other script or code block deployed inside the DTM or Launch interface that references $, but that's a separate issue to work out. Yes, it may be coming from a DTM or Launch script according to the js console, but keep in mind that DTM/Launch is a tag manager. It hosts and deploys other tags/scripts. So you need to do some digging to see which tag/script from which Rule references it. Start by looking at the stack trace to find out where it's coming from.

Deployed Vue app managed with 'webpack-simple' doesn't work

I'm working on my first Vue app, which uses the Moment library and Firebase (if that matters). I use default Webpack simple. To deploy the app I did npm run build.
But when opening directly index.html (the app is deployed here) I get "Failed to load resource: the server responded with a status of 404 (Not Found)" error message and the app doesn't work at all as a result.
I have no idea how to troubleshoot this issue since there's no more information that this in DevTools...
Any idea about what I can do next?
App source code
Remove the first forward slashes of all your assets path.
It should fix your problem.
<script src="/dist/build.js"></script> // No!
<script src="dist/build.js"></script> // Yes!
Vue adds it by default during the build process, in order to make your assets relative to the root folder.

Error after publishing .net web project

I am publishing a project in my local computer, I am getting an error because of the path of the files, in my project I am using relative path, but when i published the project I specified a Site/application so I put: localhost/myapp, but then, after the login the additional name myapp make it loses the path references, do you have any idea how to go through this?
I encountered the same problem with my web application this problem occurs because in your application you are hardcoding paths for ex :- /Home/Index or something which creates problems whenever you want to provide paths use helpers like #Url.Action(),#Html.Action(),#Url.Content() as shown below :-
#Url.Action("Index","Home",new{//specify route parameters here//})
If you are using areas in you application then specify it as :-
#Url.Action("Index","Home",new { area="myarea" })

Unexpected content from default.ctp on test.php page after fatal error

When I run a test that throws a PHP fatal error, I see my default layout (View/Layouts/default.ctp) in the output, inside CakePHP's core layout for test.php. This only happens when a fatal error occurs. Worse, content about the error is injected into the middle of some of my styled artifacts inside default.ctp, making it hard to read.
If I run a test, especially a test that does not invoke a controller, why should render() ever be called on my default layout for content?
The question is tagged 'cakephp-2.1' but could you be using a Cake core of version 2.2? This version has introduced the new error layout.
You should copy this file from: lib/Cake/View/Layouts/error.ctp to: app/View/Layouts/.
Check the migration guide.