Images are not displayed properly in .net 5 - asp.net-core

In one control I try to display images using JavaScript. Everything is fine as long as I am in the URL controller
https://localhost:44300/Campaigns
But when I refer to the index, the images are not displayed, even though I am on the same page or after the Redirect ("Index").
https://localhost:44300/Campaigns/index
The root address does not seem to be working properly
This is my image address when it works properly in Campaigns
https://localhost:44300/uploads/f09ef469-0893-4089-8491-78707d097b0e.jpg
This is my image address when it does not work properly in Campaigns/Index
https://localhost:44300/Campaigns/uploads/f09ef469-0893-4089-8491-78707d097b0e.jpg
The CSS and js address images in the layout work well, and I used UseStaticFiles() in the Configure.

It is because you are referring to the images with a URL that is relative to your current page. You need to use a URL that is relative to your site root. You can change this by prefixing the URL with / where you are constructing them.
Eg instead of something like
uploads/f09ef469-0893-4089-8491-78707d097b0e.jpg
Use
/uploads/f09ef469-0893-4089-8491-78707d097b0e.jpg

Related

Edit header in Typo3

I have a website that is running on Typo3 CMS, this was all setup by our developer, problem is he doesn't work for us anymore, all I want to do is change the url of our company logo located at the header section, I have basic knowledge of HTML and CSS, I manage to move things around in the backend, but I don't know how to change the url of our logo.
It's possible that your developer has set it in:
Typoscript (e.g. PAGE TS)
template-File (index.html in /filedmin or fileadmin/templates)
As Content Element (at the top of the Tree)
CSS
A Mix of all of the Possibilities...
Perhaps a solution:
Type the current url of the Image in the Searchbox at Top of Backend.
Another Way to find out is via Firebug (Firefox).

how to prevent changed url in the browser bar from reflecting in the website content?

how to prevent the change in the url of the browser bar from reflecting in the website content's URLS...
here is the situation,
in my current web app, I am using this
$this->createUrl(Yii::app()->controller->id ."/". Yii::app()->controller->action->id, $params)
to generate href of the hyperlinks... now the problem is,
when I type in the browser bar like e.g
www.mysite.com/blahblahblah/subcategory/c1
the blahblahblah, also reflects to the webpage content hyperlinks,because of the Yii::app()->controller->id that I passed to the createUrl function...any work around for this ?..., what i want to happen is, no matter what string is typed in the place of the controller name via the browser bar, it won't reflect in the webpage content hyperlinks ..
so how ?
the answer was, I took the ID from the URL ,created a simple Helper function and used that to return the correct value of category/subcategory and outputs it in the view source no matter what change is done via the browser bar

fixed url on address bar - show only base url http://www.mysite.com

I need to show on the address bar just the first part of the url of my site.
For example for any page with name like
http://www.mysite.com/mypage.php or
everything else
I want to see just http://www.mysite.com on the address bar of the browser.
How this can be achieved?
I tried with apache RewriteRule but with no result.
Apart from being a really bad idea for people actually trying to use your site, there is no way you can do this on the server side, because the server needs to know which page was accessed - that's what a URL is for. What you are looking for is to make it appear to the user that they are still at the same URL.
This is easy enough if you put your entire site in an HTML frameset with one frame, or an iframe sized to fill the browser window. This does require all external links to have target="_top", and without additional JS people can break out of the frame and access the pages individually anyway.
An alternative approach, that will only work on some browsers, would be to use history.pushState to fake the address bar back to / every time a new page loads.

Hotlinking: How do I differentiate between an image in a <img> tag versus an image link?

I want to allow partial hotlinking to images on my website. I want to allow a specific site (Reddit) to be able to show an image from my website on their page, but if they click on the link to the image from that site, it should go to an image viewing page, rather than directly the image itself.
For example:
This other website should be able to have this
<img src="http://mySite.com/myImage.jpg"/>
on their page, and it should show the image. However, if they have this:
Link Text
A user who clicks on that link should get redirected to an image viewing page that contains some html, including the image, rather than directly to the image.
I'm trying to achieve this via mod_rewrite. However, those two cases have the same HTTP_REFERER. Is there anyway for my server to differentiate between that?
There is no way to do such thing! but if second site is your you can put optional query string at the end of URL the distinguish between them!

Can I force all links in a WebView (or WebFrame) to be treated as absolute paths?

So I'm working with WebKit's - WebView and WebFrame. I use a custom NSURLProtocol to retrieve the HTML for each request from a database. The problem arises from the fact that the links in the HTML are all relative, when they really ought to be absolute. For example, the page
foo/bar.html
May have a link in it that points to
foo/baz.html
The problem is that since the link is relative, the request ends up being for
/foo/foo/baz.html
So far, I've tried to work around this by comparing the two URLs and stripping off the common prefix - in this case 'foo/' - leaving me with foo/baz.html. This doesn't work for all possibilities, however, especially when there are multiple directories in the path. I do this in the "didStartProvisionalLoadForFrame:" method of my WebView's frameLoadDelegate.
Unfortunately, I do not have control over the HTML that I'm displaying, so modifying the links themselves is not an option.
Try being the main frame's resource load delegate, and implementing webView:resource:willSendRequest:redirectResponse:fromDataSource: to modify the URL being requested. Send relativeString to the request's URL to get the original relative URL, then use -[NSURL initWithString:baseURL:] to create a new URL with the same relative string against the correct base URL.