When the application is deployed, the image does not appear - blazor-server-side

I use this code to show image
<button type="submit" class="buttonstyle"><img src="/images/Logout.png" alt="Logout"></button>
Working fine on development machine .
But when I deployed to the server (Windows Server 2019) the folder is on partition C
I got this error
Failed to load resource: the server responded with a status of 404
(Not Found)
I try with this
src="../wwwroot/images/Logout.png"
And I try to use a full path
<button type="submit" class="buttonstyle"><img src="#logoutImage" alt="Logout"></button>
#code{
string? logoutImage = $#"{Directory.GetCurrentDirectory()}{#"\wwwroot\images\Logout.png"}";
}
I got this error
Not allowed to load local resource: file:///C:/SmartHR/wwwroot/images/Logout.png
Update
Any Help .

After reading this article
Host and deploy ASP.NET Core Blazor
I found this
Do not prefix links throughout the app with a forward slash. Either avoid the use of a path segment separator or use dot-slash (./) relative path notation:
❌ Incorrect: <a href="/account">
✔️ Correct: <a href="account">
✔️ Correct: <a href="./account">
After removing the forward slash from <img src="images/Logout.png">
Everything works fine.

Related

Utilising the error layout in a hosted Nuxt application

I've just finished creating my custom error messages in my Nuxt.js application in layouts/error.vue. For the moment I've made it pretty simple as it's just a brochure site for the time being, so I am just handling the errors as shown below as for now I only care about users hitting a page that doesn't exist.
<template v-if="error.statusCode === 404">
<h1>Sorry!</h1>
<p>We can't find the page you are looking for.</p>
</template>
<template v-else>
// Some other message
</template>
When running my application locally, and trying to navigate to a route that doesn't exist, this works perfectly and my error message is displayed.
However, my hosted application does not behave how I want it to. I'm hosting the application on IBM Cloud as a Cloud Foundry application. The application uses the static buildpack, and my manifest.yml file looks like so:
---
applications:
- name: name
path: ./dist
buildpack: https://github.com/cloudfoundry/staticfile-buildpack.git
random-route: true
But if I try and navigate to an incorrect route that way, I am displayed the generic nginx 404 error:
I understand that there are 2 ways you can tell Cloud Foundry that the application requires a static buildpack - Declaring the buildpack in the manifest.yml OR adding a file named Staticfile in the dist directory after running npm run generate. Within this file, you can add some configurations, one of which being status codes which:
Allows to define custom pages for HTTP STATUS codes instead of the default NGINX pages.
status_codes:
404: /404.html
500: /500.html
However, my error handling is done in a layout, not a page. And my generated project folder does not contain a page called error anywhere, so I don't know how to use this method to use my error handling.
If anybody could give me some pointers on how to correctly do it, it would be greatly appreciated!

Selenium HtmlUnitDriver Web Scrape Got Captcha Page From EC2 Server

I wrote a simple web scraper to scrape expedia.com. Using Java Selenium HtmlUnitDriver, i was able to successfully scrape data from the site if i run it locally.
However, when i deploy this on to an EC2 Server, it always returns me the page where expedia detected it as a bot, thus, it displays this captcha to prove a human is accessing it.
I think it might have something to do with ip address of ec2 servers which got blacklisted by expedia.com somehow?
I've tried scraping different websites where they don't care / don't do human test.
Any idea how to go around this?
Things I tried but still detected as bot:
Changing user agent to something i use on my local browser
Setting a proxy
Update:
Actually setting a proxy server gives me a different error:
Current URL is https://www.expedia.com/things-to-do/search?location=Paris&pageNumber=1
The htmlString:
<!--?xml version="1.0" encoding="ISO-8859-1"?-->
<html>
<head>
<title>
500 Internal Server Error
</title>
</head>
<body>
<h1> Internal Server Error </h1>
<p> The server encountered an internal error or misconfiguration and was unable to complete your request. </p>
<p> Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error. </p>
<p> More information about this error may be available in the server error log. </p>
<hr>
<address> Apache/2.4.18 (Ubuntu) Server at www.expedia.com Port 443 </address>
</body>
</html>
Are you covering these topics:
-Which agent are you using? Make sure you are using the same agent which you would use in a human navigation, more details in this link.
-Are you inserting waits in your navigation? If as soon as a page load you try to click or navigate, this isn't simulating a regular navigation. More details.
-Which driver are you using, there is a trick with chromedriver to rename a internal variable "cdc_" to other name like "aaa_" then if there is a javascript code in the server trying to detect this variable (cdc_), it will fail. More details.
-There are more things to be studied if you really need to not be detected by the server:
-Is there a honeypot in place?
-Are your IP (EC2 IP) already blocked? You could redirect using a VPN tunnel.
Interesting articles:
https://www.kdnuggets.com/2018/02/web-scraping-tutorial-python.html
https://antoinevastel.com/bot%20detection/2017/08/05/detect-chrome-headless.html
https://intoli.com/blog/making-chrome-headless-undetectable/

SSI/mod_include: new ap_expr syntax not working as documented

My website uses SSI (server-side includes) to check a condition (using #if expr) and return different HTML code based on whether the condition is true or false. This used to work fine for years until recently, my website started showing the error [an error occurred while processing this directive]. I found out that the expr syntax changed in newer versions of Apache httpd, so I assume that my hosting provider upgraded the Apache httpd recently and that caused the old syntax to break. The Apache httpd is now at version 2.4.29.
I managed to fix the problem temporarily by adding SSILegacyExprParser on to my .htaccess file to go back to the old syntax (thanks to this question). But I would like to find a permanent solution using the new syntax.
Here is the old syntax SSI code that works with SSILegacyExprParser on:
<!--#if expr="${thisDoc} = /impressum\.shtml/" -->
<li id="current">
<!--#else -->
<li>
<!--#endif -->
(The variable thisDoc has been set earlier.)
Here is the SSI code using the new ap_expr syntax that doesn't work. It shows [an error occurred while processing this directive] again. I was following the documentation at http://httpd.apache.org/docs/current/expr.html when writing this code:
<!--#if expr="%{thisDoc} =~ /impressum\.shtml/" -->
<li id="current">
<!--#else -->
<li>
<!--#endif -->
I've tried modifying the syntax in various ways, for example to avoid using regex matching and use exact string comparison instead, but that didn't work either. I couldn't get a single expression to work in the new syntax.
Why is the new syntax not working?

The web address incorrect error

I am new to windows 2012 server as well as iis8. I try to host a sample page with domain name in IIS8. I got following error
Make sure the web address http://www.mytest.com:1024 is correct
How can I rectify this? First created a new website called MyTest and assigned the ip address and port number to that site and set the domain as www.mytest.com.
Sorry for my bad English and thanks in advance.
My code in html page is
<html>
<body>
Welocme
</body>
</html>
try executing your page using url like
http://localhost:1024

wrong paths on multi website magento install

I am running a magento 1.7.0.2 instance with WAMP 2.1 on Windows 7. My goal is to set up one magento store, and one
I followed the tutorial described here and I setup website profi on a subdirectory, but when I accessed the frontend on http://localhost/profi/ the first thing I noticed that the images paths were broken.
Broken: http://localhost/bms/profi/skin/frontend/default/default/images/logo.gif
Correct:
http://localhost/bms/skin/frontend/default/default/images/logo.gif
This is the same for the JS & CSS files. I've made the following modifications to the index.php file in the profi folder:
$mageFilename = MAGENTO_ROOT . '../../app/Mage.php';
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'profi';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';
It was a matter of configuring the second website's URLs.
I went to System > Configuration > General > Web > Unsecure. The Base URL was http://localhost/profi/ and I added ../ to the following the following:
Base Skin URL: {{unsecure_base_url}}../skin/
Base Media URL: {{unsecure_base_url}}../media/
Base JavaScript URL: {{unsecure_base_url}}../media/
That did the trick. I see on the frontend everything looks in order. Hope I won't run into anymore problems with this set-up.