not allowed to load local resource image file:///C:/uploads/images - asp.net-mvc

I'm trying to get a photo URL but I get a 'no allowed' error message.
The URL comes like C:\\upload\images, but on chrome it looks like like C://upload/images.
How can I solve this problem?
#foreach (Product pro in Model.Products)
{
<div class="col-lg-4 col-md-6">
<div class="single-product">`enter code here`
<img class="img-fluid" src="#pro.ThumpNailPicture" alt="">
<div class="product-details">
<h6>
#pro.Name
</h6>

I'm not quite sure what you are asking, but in general it is best to serve content over HTTP rather than directly from local disk. This can be done either via the wwwroot folder or a dedicated static content server.

Related

Encoding::InvalidByteSequenceError in Home#index "\xA9" on UTF-8

I'm new to Ruby on Rails, and have been battling with this issue for a while now.
I have pulled a website from git, and made sure all the dependencies are installed, however, when I run the site, I get the error:
ActionView::Template::Error ("\xA9" on UTF-8)
because of the line linking images using the code image_path("bground2.jpg").
When I remove the image_path("bground2.jpg"), the error is resolved.
I however need image_path("bground2.jpg") and can't do without it.
I have tried the solutions here, but it seems not to work
This is a section of the index.html.erb file, but the error is recurring over all places containing the image_path and image_url:
<%= provide(:title, 'Home') %>
<section id="slider" class="">
<div class="img-responsive" style="background-image: url(<%= image_path("bground2.jpg") %>); background-position: 50% 0;height: 500px;">
<div class="container clearfix">
<!-- <div class="slider-caption slider-caption-center">
<!-- <div class="banner heading-block title-center nobottomborder">
<h1><%= "#{t('.reach_home')}" %></h1>
</div> -->
So, I solved this by reinstalling the Ruby application.
Don't know what had caused it, but I just reinstalled the application and everything works fine.
Thanks all for the help.
I had this very same issue. I identified it to a file I had in my application, actually it was taking place in minified javascript file I had in my Rails app. I open the file in text editor, added a new line and, set the encoding as UTF-8 and saved it, and the problem disappeared.

Not able to follow link | Behat/Mink

Am not able to click on links using Behat/Mink. There's a desired text in <span> tags so maybe this could be the reason?
This is part of my *.feature file:
Scenario: Tryin' to make it freakin' workin' yo!
Given I am on "/home/"
And I follow "Test"
Then I should be on "/test/"
And this is part of the page am trying to focus on:
<li id="ApplicationItem_test" class=" " data-placement="right" rel="popover" data-offset="-6" data-content="" data-original-title="test">
<a href="/app/tests/e76ee2a8d9094e11b6bb9c928c5d61e3/" data-subscription-id="e76ee2a8-d909-4e11-b6bb-9c928c5d61e3">
<i class="picon-money-icon-16"></i>
<span class="expand-element">test
</span>
<div id="nodeCounter_c592e0ce62c849fab427fc9f2a04b557" style="display:inline-block">
</div> </a>
</li>
<script type="text/javascript">
var node = { id: '#nodeCounter_c592e0ce62c849fab427fc9f2a04b557', action: '/app/tests/e76ee2a8d9094e11b6bb9c928c5d61e3/GetSidebarActionCount' };
Access.SideBar.nodesWithCounters.push(node);
</script>
And this is the error I'm getting:
And I follow "Test"
FeatureContext::clickLink()
Link with id|title|alt|text "Test" not found. (Behat\Mink\Exception\ElementNotFoundException)
Have tried all possible CSS selector functions found on the internet. Also am wondering if I shouldn't use the Selenium extension for Behat here (because of the JS?)
So answer is: I wasn't on the right page.
Basically Scenarios should be independent - that means my previous session was burnt and I missed some previous steps (login, for example.)

Images on Rails not showing up on my browser

I am trying to include an image in my web application but it is not showing up properly on my browser(localhost:3000). Have I set it up wrongly?
This is my view code:
<div class="row">
<div class="col-sm-4">
<img src="‪assets/img/Lab Potion.png" alt="#" class="img-responsive">
<h2>random text</h2>
<p>random text</p>
</div>
</div>
I downloaded an image and saved it under:
-Desktop
-rails_projects
-project_name
-app
-assets
-images
When I check in the images folder there is a file named Lab Potion.png and a bunch of random numbers inside(fingerprint?)
Why is the image not showing up?
<%= image_tag('Lab_Potion.png', :style => "z-index:19; position: relative; float: right;") %> will work. get rid of the space in the file name too, if not just for my sanity.
The random numbers are like a security feature and on each precompile the numbers end up changing. It's more complicated than that, but that is the gist.
And lastly, i doubt you have a img folder as well.

How to use external image inside phonegap/jquerymobile app

I'm developing a phonegap/jquery-mobile test application (I'm new in this technologies) for android and I want show inside my app an image stored on internet site. During app startup in avd I receive this notification when put in my index.html this element:
<img src="http://www.comolakeboats.it/images/stories/boats/gommone_12_150x100.jpg" width="120px;" />
Application Error - the connection to the server was unsuccessfull (file:///android_asset/www/index.html)
On log.cat I can see this error:
E/DroidGap(337): DroidGap: TIMEOUT ERROR! - calling webViewClient
I already checked connection both from browser and inside my application with an external link and in both case I can reach internet site.
What I'm missing? Exists a solution (maybe the same) suitable for Iphone,too?
This is my code:
<body>
<div data-role="page" id="home_it">
<div data-role="header" data-theme="a" id="it">
<h1>TEST</h1>
<div data-role="navbar" data-iconpos="right" data-theme="a">
<ul>
<li>Tel:+3933333333</li>
<li>Email</li>
</ul>
</div>
<div class="ui-body ui-body-c"><!-- ui-body-b">-->
<p>Some text</p>
<button id="my_list_button">Mostra</button>
</div>
</div>
<div data-role="content" class="ui-body">
<ul data-role="listview" id="my_list">
<li data-role="list-divider">My list</li>
<li>
<a href="http://www.comolakeboats.it" rel="external">
<img src="http://www.comolakeboats.it/images/stories/boats/gommone_12_150x100.jpg" width="120px;" />
<h3>title foo foo</h3>
<p style="color:red">foo foo foo foo</p>
</a>
</li>
</ul>
</div>
<div data-role="footer">
<div data-role="navbar" data-iconpos="right" data-theme="a">
<ul>
<li> </li>
<li><a id="exit-app" data-icon="back"> </a></li>
</ul>
</div>
</div>
</div>
</body>
Thank you in advance
Did you actually update the phonegap's whitelist? that tells the app which URLs it's allowed to access. You can also add a * to it, as described here
Hope this helps
If you put higher values in defaultactivity:
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/index.html", 60000);
It won't time out but it will take ages for your app to run...
Maybe the most simple you can do is download the image and add it to your project. In that case just make the src attribute of the <img> tag reference the image path inside your project.
A few notes that might help you:
the index.html has to be a full html document ...
you have to set the permissions to use the internet, in AndroidManifest.xml
the test device has to have an internet connection (try opening the image url on the device browser first).
I have set the whitelist in my cordova.xml to ".*" but it still displays the same error so I tried looking for other solutions and found this out:
http://community.phonegap.com/nitobi/topics/phonegap_build_viewebclient_timeout_error_on_android_device
His solution was to redirect the page from the index.html to a main page. I don't know why it worked for me but happy that it did. If you would see any problem doing this work around please do comment, I don't want to encounter other major problems in the future because of this.
I have the same problem. Finally i find the reason is "Content-Security-Policy" setting in head of the html!. You can simply remove the line like this:
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

How to integrate Yoxview to Rails 3 application when pictures are protected by Controller?

I'm trying to integrate Yoxview to my Rails 3 application that uses Paperclip to upload pictures.
The main problem is that the pictures (both original and thumbs) are not in the public area, i.e. they are accessible via Controller as described here.
The relevant HTML looks like:
<div id="my_wrapper">
<img src="/assets/1/thumb" />
<img src="/assets/2/thumb" />
</div>
When a thumbnail is clicked, I expect the Yoxview player to be opened, but what happens is that the original picture is opened in a browser.
When the pictures are in the public area like this:
<div id="my_wrapper">
<img src="/images/thumbs/1.jpg" />
<img src="/images/thumbs/2.jpg" />
</div>
everything works perfectly!
Any ideas ?
UPDATE
I tried also:
<div id="my_wrapper">
<img src="/images/thumbs/1.jpg" />
<img src="/images/thumbs/2.jpg" />
<img src="/assets/1/thumb" />
<img src="/assets/2/thumb" />
</div>
Here, if I click on thumbs/1.jpg or thumbs/2.jpg the player is opened properly, but shows only these two (original) pictures. If I click on one of the other two thumbs, their original picture is opened in a browser.
I found the answer. It's so simple. Just had to use the allowedUrls option of Yoxview:
allowedUrls: /^\/assets\/\d+\/(thumb|original)$/i

Resources