Can not find image path in web application - asp.net

I am using asp.net mvc 4.0 application.
I am using II7/II8.
I have configured my web application under following way in IIS in following way
Default Web Site\MyWebApp
When I am trying to browser my page in local machine
http://localhost/Home in that following image is rendered. This image is surely available at /Content/Images/ but not loaded properly, when in browser I do inspect element and alter the path like /MyWebApp/Content/Images/ it is loading an image properly.
<img alt="close" style="cursor: pointer;" src="/Content/Images/ic-delete.png" onclick="closePopUp('dvclose');">
While in live server IIS , I have website like www.xxx.yzx and when I am trying to browse
www.xxx.yzx/home it is loading image properly
i am trying to do somthing so I don't want to bother to change path(remove MyWebApp) of image when I am deplying. I don't want to move my application from Default We Site
What to do for loading image in local machine?

Posting my comment as the answer:
~/Content/Images/ic-delete.png Try that as the src.

Related

ASP.NET MVC 4 Application on IIS 8 not showing png images

I deployed asp.net mvc 4 application on windows 2012 server today. Everything is working fine but no png images are loading.
The below are the screenshots
These are some things I checked
I can load different images in this folder except the ".png"s.
Static Content was installed on my webserver.
Check MIME types .. png are included there
Added the following code to route config
routes.IgnoreRoute("{resource}.png")
Also checked the advanced Attributes by going into the properties of the file on webserver. The below is the screenshot.
Try use this:
<img src="<%= Url.Content("~/Content/logo.png")%>" alt=""/>

IIS smooth streaming does not play a video on asp.net MVC 4 with Razor

I am trying to get a basic demo working but can't succeed, I've spent hours and hours on it..
I am building an iis smooth streaming player with no controls at first that auto plays the video, I am using "MMP"- Microsoft media platform which was formerly "SMF"- Silverlight media framework, the example I am using to build a smooth streaming player is here on the middle of this page: http://smf.codeplex.com/documentation
A brief explanation of the issue I am facing:
I am sure I got everything right in terms of the player itself, I got the .ism file, i can view its manifest if I browse to it with the browser, I can even get everything to work and play the video in an html file that is running straight from an IIS website.
another key note: I can also run any test silverlight application for example, the main form with a button and a few radio buttons and I do get this application to run and display. the problem happens only when I try the smooth streaming player, it gives a black and blank page for the whole page and right clicking shows "silverlight".
so the problem starts when I try to run it from a Silverlight application that is hosted in an asp.net MVC 4 (with Razor) application.
I have an asp.net MVC project in visual studio and then I add a silverlight application to it and choose to host it in the MVC application, then I follow the same routin as for the silverlight application player building and it even renders and plays the video on the visual studio's silverlight XAML design page. I build the whole solutio and then I get a "silverlightApplication1.xap" file in a "ClientBin" new folder on the MVC application and also a test html file and an test aspx file again in the MVC application.
if I make sure the linking is correct I can take this html file to another IIS website and run it from there and it works and plays! but if I try to run it straight from within the application (view in browser) for the html/aspx files it says that it's not running on the platform/fabric of the website and for the silverlight application itself it opens the same blank silvelight application with a black screen and also a URL of file:// and not http://localhost.. etc', so what I was trying to do for a long time is to make the silverlight application work as a view in the MVC application.
so I took a view and deleted everything in it and gave it a property of Layout=""; (nothing) and then I put the content of the test html file the SL application produced earlier, modified the value for the silverlightapplication path etc', when built and ran, the page comes up, even the application comes up as I see "Silverlight" on a right click of the mouse but the whole screen is just plain black again and it doesn't play the video.
I had the .ism file on anther location or a an entirely different location like another online website.
I also can't get to view the manifest when I run the MVC application it says its 404 but I am not sure if it's an MVC platform thing that it won't let me get to it or it's just not getting to it but the files are there and the URL's are correct both in the code and also in the URL i am putting in.
I have also came to the understanding that I might need to make sure the silverlight application is allowing cross domain traffic and it has a Client access policy like seen on this page: http://msdn.microsoft.com/en-us/library/cc838250(VS.95).aspx , so I've added two XML files to the root folder for these two issues. trying to figure out what's going on with firefox's web developer gives nothing as for what happens..
Please Help! Thanks! :)
Ray.
I don't know why and I have tried everything+making sure I get the manifest content if i browse to it.
it just worked with this URL for the ism file:
http://video3.smoothhd.com.edgesuite.net/ondemand/Big%20Buck%20Bunny%20Adaptive.ism/Manifest
there was no need for cross domain xml and Client access policy xml.

referring the image files from the Trdion server in Dreamweaver TBB in SDL Trdion 2011 Sp1

I am trying to refer the Images from the Web server of the Tridion.
<img src="file://///ServerAddress.com/applications/Images/Styles/temporary.jpeg" alt="alt text"/>
I have added this code my TBB.
The image is not getting displayed.
Added the same code in local html page in my machine, I am able to retrieve the that Image.
Edit:
Image is not getting displayed while previewing in Tridion CME.
Can any one suggest how to configure my image source path in TBB for accessing the Image.
Thanks in Advance.
You are using a file:// URL, which means that you are referring to a local file on the machine that opens the HTML. So when you open the HTML on the machine where you originally created it (and placed temporary.jpg), it will find the file locally and display it.
When you open the same HTML from any other machine, it will fail to find the file on that machine and thus won't display the image. The fact that you use ServerAddress.com makes no difference for that: file URLs will only resolve to file on the local machine.
If you want to ensure your images work properly for the rest of the internet too, use a more common protocol such as http://.

newbie question about css property set up in Web developer 2010 Express

I am relatively new in C# and ASP.NET MVC.
There is something unusual that happens and it could be a simple property setup...
I have a MVC Web app and a css file associated with it in my Content folder.
Now everytime I do some changes in the css file I don't see these changes when I run the app. It seems that whatever I do the app keeps on using the old file. I can see it when I do a View Source on the page.
I played a bit with the Copy to Output Directory property in Web Developer without any good results.
Am I really missing something here ?
Thanks
Either restart casini, the web server for asp.net, the icon down by the clock or try hitting F5 in the browser a bunch of times.
Try clearing the cache in your browser.

Can't read images from C:\ in ASP.NET

I realize this is an edge case, but it seems that asp.net doesn't allow reading images from the root drive. To test this I wrote the following very simple application:
On the page I have:
<asp:Image ID="test" runat="server" />
In the code behind I have:
test.ImageUrl = #"C:\test\image.jpg";
test.AlternateText = File.ReadAllText(#"C:\test\text.txt");
Both files exist as you'd expect and have the correct permissions. When viewing the source of the page we get an img tag that looks like the following:
<img id="test" src="C:\test\image.jpg" alt="some text to read" style="border-width:0px;" />
When I run this in VS no image is displayed. If I copy the source, paste it into an html file and load it into a browser the image is displayed. Can anybody explain why this is?
The src of an img tag should rarely point to a file on your local disk. It should be an URI. Perhaps you'll have more success using the file:///C|/test/image.jpg syntax.
The browser is preventing the images from being displayed. I created a static HTML page containing an tag whose "src" pointed to an image on my local file system. If I open the HTML page locally, everything works as expected. However, when I hosted the static HTML page in a web server, it stopped working.
I ran ProcMon while loading the HTML page from the remote server, and the local file was accessed (some columns truncated for display purposes):
iexplore.exe 6376 QueryDirectory C:\test.jpg SUCCESS test.jpg
iexplore.exe 6376 QueryOpen C:\test.jpg SUCCESS
iexplore.exe 6376 QueryDirectory C:\test.jpg SUCCESS
iexplore.exe 6376 CreateFile C:\test.jpg SUCCESS
iexplore.exe 6376 ReadFile C:\test.jpg SUCCESS
iexplore.exe 6376 CloseFile C:\test.jpg SUCCESS
However, IE did not display the image. I repeated the test with Firefox. When accessing locally, the ProcMon results were the same. When accessing remotely, ProcMon didn't produce any output.
It has to do with the way you're assigning the img src. By providing C:\test\image.jpg as the sourc you're instructing the BROWSER to get the image from the user's local drive rather than from the server's location.
All src directories/files should be specified using relative paths for your website. For example: If your homepage was located on your server at c:\www\homepage.aspx and you also had an images sub-directory located within the www directory then you'd want to specify your img src to be something like this: <img src="/images/image.jpg" alt="Image" />
I know that you said the permissions were correct, but double check and make sure the aspnet\aspnet_wp account has permissions to the file location. When you run an asp.net application it runs under this account. When you load an HTML file in your browser, it runs as you.
This is because you're feeding a "URL" into the src tag, and the browser treats it as such. When you open a file such as C:\test.html it is simply rendered by the web broswer and uses the local source as the starting URI, but when you load from another source, such as http://localhost/test.html then the file needs to be accessible through http, and http://C:\test\image.jpg is not a valid URL.
Seems to work properly if you use a url. Not sure what the difference there would be though.
This is a browser security "feature". The goal is to prevent malicious websites from accessing your local files, and causing them to either be executed or uploaded to the website without your knowledge.
In order to get past it I believe you will have to change your security zone to "local intranet", then drop the security down to pretty much allow everything.
Obviously this is only viable for machines you directly control.
The html code is invalid. It should not render in any browser, VS, firefox, IE or any other. In fact it does not in firefox.
If You display images from C: drive or any local drive in a server side web application development. It will create conflict-ion from client drive if they are same file and folder name in client computer. That's why you Can't read images from C:\ in ASP.NET.
To read the images from local server drive first you will to create virtual directory for your local drive(C:\Gallery) then you can display images from folder.
example:
<
asp:Image Id="Image1" ImageUrl='<%# Eval("Filename", "http,://localhost/ImageGallery/{0}") %>' Width="150px" Height="150px" runat="server" />
please remove from http, like http
Shankar Chaurasia

Resources