BDubCook
BDubCook

Reputation: 488

Images load in all browsers but not in UIWebView

I have a website that is set up as an application underneath another site on my server. all the javascript, css, and image files are set as relative paths. When I had the site as it's own top level site everything worked in all browsers as well as in the mobile app I created that contains a UIWebview.

When I moved the site as an IIS application underneath another site of mine everything that was set as src= stopped working. I went through and adjusted the HTML to load the Request.FilePath (virtual Path) for all of these and everything started working again...except in the UIWebview of my app. Has anyone run into this before and why does this happen? the site works fine if I open safari on my phone.

HTML

    <% string rootPath = Request.FilePath; %>
    <img src="<%= rootPath %>/Resources/image.png" />

Source

    <img src="/WMS/Resources/image.png">

Once again this is working in all browsers (IE, FF, Safari) but when I open it up in a UIWebView the image doesn't load

I'm using .NET 4, IIS7, MVC2, iPhone 4 with the latest SDK

Any help would be appreciated

Upvotes: 4

Views: 427

Answers (2)

Rashad
Rashad

Reputation: 103

I had this problem too, I've fixed it by using Url.Content. try something like this: src="<%= Url.Content("~/Resources/image.png") %>"

Upvotes: 2

Joshua
Joshua

Reputation: 3603

Three things come to mind:

  1. Caching - UIWebView's cache is to the broken link?
  2. IIS is serving static files with improper MIME types?
  3. (I'm reaching here) Is your mobile test device on the same network / domain?

Upvotes: 1

Related Questions