My application is an Api ASP.Net, and I save the images in the "wwwroot" folder
Content
When I publish my application that structure is created as well and I want to access the images through a URL
From Client Angular 2
<img src="{{ 'http://192.168.1.20/Api/api/uploads/Koala.jpg'}} " >
(Not Found)
I must mention, that my application is published locally, and users connected to the network must access the images
Question
How to access the image found on the IIS server with the Url?
I am right?
Correct me if I'm wrong
Thank you all
First try to access the image url on the browser i.e.,
http://localhost/Api/api/uploads/Koala.jpg
If it displays the image then there is not problem with you IIS hosting.
Now try the same url from a different machine in the network i.e.,
http://192.168.1.20/Api/api/uploads/Koala.jpg (from a different machine)
If it does not work then make sure that you machine accepts http inbound traffic over the network.
Use tilde ~ for relative URL in paths:
<img src="{{ '~/uploads/Koala.jpg'}} " >
Based on my understanding, you shouldn't specify the full URL in <img src="{{ }}">.
If you want to specify full URL in Src attribute, you don't need angular. You should just remove {{''}} and modify the URL to
<img src="http://192.168.1.20/Api/api/uploads/Koala.jpg" >
If you want to use angular2 in this case, you should just modify the URL like
<img src="{{imageUrl}}">
Then declare the variable imageUrl in Component.
Related
When I used Nextjs Client with http and C# Api with Http, I can make the client show the images which is saved in the virtual directory. But when I upgrade my nextjs to Https, the images do not show anymore. As I see in F12 in client, all of my image path was converted to have https. Eg: http://domain.info/images/filename.jpg was converted to https://domain.info/images/filename.jpg
I use IIS Window Server to upload my code.
My image code:
{logoData ?
<div className="logo">
<img className="img-fluid" src=
{BaseGatewayImage + logoData.imagePath} alt="Newsprk" data-lazy-src=
{BaseGatewayImage + logoData.imagePath} />
</div> : <></>}
this is the images after https:
Images after https
Can some one help me with this case? Do I have to upgrade my api to https?
I have this image URL i got from database.
\\Imagepath\ImageFolder\image.png
but i need to put in a img tag in html to show the image in the page, i try to do this way
<img src='\\Imagepath\ImageFolder\image.png'/>
but the page adds the default url for localhost, ie.
http://localhost:1234/\\Imagepath\ImageFolder\image.png
I need your helpfor trying to get the image from that server URL.
I have a lot of images around 6,200 so is not an option to download, i'm show the images in a table.
NOTE: i know the img tag not accept the URL like i have, but maybe you have an idea to do in ASP.NET, i apretiate your help.
NOTE 2:i'm using ASP.NET MVC.
Paths starting with \\ are UNC paths, they are not URLs. In a browser, you have to use a URL to load an image.
The browser is assuming you've tried to specify a relative URL, and is attempting to add the current URL by default in order to fully qualify it and then make a request to it to get the image.
You need to map the path to a virtual directory in your webserver and then point the image's src property at the URL of that virtual directory.
Alternatively, if that's not a workable solution you could write an MVC action method which takes the name of the image file as a parameter and then loads the image from the UNC path in the background and returns the data in a binary response to the browser.
I have a web project and I am using the webforms report viewer. I created some local reports. All I want to do is link one of the columns on the report to a query string clientID that will navigate to a local page within the website and on that page I will request the query string of the the ClientID and load that client.
="https://devserver002/MyWebsite/Reports.aspx?ClientID="&Fields!ClientID.Value & "&Key=2"
I have created an Go to URL Action on the textbox of that column the URL above.
This works it reloads the reports.aspx the clientID is requested and the client is loaded.
The Problem
How do I create this link to go to just a local page within my website without specifying the server within the address? ="https://devserver002/
Currently its on a development server and it will be transferred over to a production server. Its bad programming to put the server name within the URL because if you change servers the program is now broken. How could I navigate without specifying this server within the URL using these reports?
Within the Report RDLC XML the link that works is
<ActionInfo>
<Actions>
<Action>
<Hyperlink>="https://devserver002/MyWebsite/Reports.aspx?ClientID="&Fields!ClientID.Value & "&Key=2"</Hyperlink>
</Action>
</Actions>
</ActionInfo>
Simple, create a DNS A record on your local DNS server. If you're going to use it on the internet, then you will have to register a domain name and create a DNS A record.
However, if it only a Intranet, you just have to add the record to your local DNS server. If you not, you might have to create a hosts record on all your client workstation(worst case).
In addition, don't use the "" in your coding. Just root operator (~).
For example:
"~/Reports.aspx?ClientID="&Fields!ClientID.Value & "&Key=2"
In addition, you can always use the loopback IP of 127.0.0.1 instead of the server name.
"https://devserver002/MyWebsite/Reports.aspx?ClientID="&Fields!ClientID.Value & "&Key=2"
and this
"https://127.0.0.1/MyWebsite/Reports.aspx?ClientID="&Fields!ClientID.Value & "&Key=2"
Should not make a difference.
Try this:
https://localhost/MyWebsite/Reports.aspx?ClientID="&Fields!ClientID.Value & "&Key=2"
Addition:
Take a look at this link, Click here. Here is a video that might help you too: Click here to see video
I have a file upload control on .aspx page where I am extracting basic file information. The requirement is that I need to save absolute path for selected file from client's machine to a db.
I have read on this site as well as else where that by nature ASP.NET doesn't allow to read information from client's machine for security reason.
But I am wondering if there is a way around this issue using js or something to get the absolute path and then pass it to asp.net variables?
You can't really do anything reasonable about this restriction.
Any fully trusted code on users' machine can do that. So your goal is to convince user to install something that will provide you with the information.
For Windows (all require instalation of some sort):
ActiveX controls
Native EXE
Locally installed managed EXE
locally installed HTA for IE only
I believe almost all platforms also have ways to to so... with similarly painful installation requirements.
You can't get client machine path. For security purposes, the browser will never post the full file's path.
You can't get full path of the file.
For security purposes, the browser will never post the full file's path.
Try to use below code in java script.
lbltext.Text = FileUpload1.PostedFile.FileName
Browser send file without full file path, so to retrieve file path you do it on client side via javascript function:
<script type="text/javascript">
function OnSubmitHandler(myForm)
{
var fileUpload = document.getElementById('<% = FileUpload1.ClientID %>');
myForm.action = myForm.action + "?FilePath=" + fileUpload.value;
return true;
}
</script>
<form id="Form1" method="post" runat="server" onsubmit="return OnSubmitHandler(this);">
...
<asp:FileUpload id="FileUpload1" .... />
...
</form>
If you don't want to send a file path via query string, you can create hidden form field, so file path will be sent via post.
I have a situation in which there is a login page.After successfully logging in,i 'm redirected to http:\localhost\default.aspx.I want that after logging in my browser url should look like www.abc.com but the pa ge opened would be http:\localhost\default.aspx.I'm not able to do this using URL rewriting
Unfortunately, this is not possible for internet users - you can't 'fake' the URL that your user is looking at. Otherwise evil-doers could re-write 'www.istealyourmoney.com' as 'www.trustworthybank.com', etc.
The only possible option I can think of is if your users are all on the same local area network. In that case, you can add an entry to your HOSTS file with www.abc.com aliased to 'localhost'.
As said by JBRWilkinson this is not generally possible, however if you want to do this just to help you build out a site while you work on it locally, add an entry to your HOSTS file (on Windows: C:\Windows\System32\Drivers\Etc\Hosts) that maps www.abc.com to 127.0.0.1. You want to add a line that looks like this to the end of the file:
127.0.0.1 www.abc.com
Then you can access your local development website with the URL www.abc.com. Note that this will also block access to the live version of that website on your machine.
can't we achieve using IIS url rewrite?
http://www.codinghorror.com/blog/archives/000797.html