I'm building an iPhone app on Monotouch. Part of my project use local website content. I copy all html, js, css and images used for the website in a folder and import this to my monotouch project. I have set build option for all of these files to Content.
I load the local web content like below:
this.url = Path.Combine (NSBundle.MainBundle.BundlePath, "Content/index.html"); webView.LoadRequest(new NSUrlRequest(new NSUrl(this.url, false)));
The problem is when I run the project, it cannot find my local website and the I got the message below when I try to debug:
The requested URL was not found on this server.
/Users/*****/Library/Application Support/iPhone Simulator/4.3/Applications/092E0D85-92F4-4F4E-9CD2-3FBBCD797F76/Project.app/Content/index.html
The funny thing is when I copy the link to safari, the web is displayed without any problem
I have tried to clear and rebuild the project few times but nothing changes.
Can anyone help me with this?
I'm using OS X Moutain Lion 10.8.2, MonoDevelop 3.0.5, Monotouch 6.0.6, xcode 4.5.2
Thanks in advance
It's strange, worked well for me.
Try this instead:
var fileName = "Content/index.html";
webView.LoadHtmlString (File.ReadAllText (fileName),
NSUrl.FromFilename (fileName));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With