我遇到了类似的问题:https://forums.xamarin.com/discussion/6319/problem-with-webview-and-url
使用 UIWebView
,我试图传递带有查询字符串的 URL。 URI 如下所示:"Content/Content/holder.html/?contentpath=/test.html"
没有查询字符串,文档显示正确。但是,对于查询字符串,我收到以下错误:
Error Domain=NSURLErrorDomain Code=-1100 “在此服务器上找不到请求的 URL。”
它似乎没有分隔查询字符串。
我已经阅读了一些 C 解决方案,但我无法在我的 C# 解决方案中反射(reflect)出来;特别是
NSString *URLString = [url absoluteString];
NSString *queryString = @"?param1=1";
NSString *URLwithQueryString = [URLString stringByAppendingString: queryString];
最佳答案
在这里找到我的答案:https://forums.xamarin.com/discussion/10444/uiwebview-loadrequest-encoding-url-so-becomes-3f
UIWebView 不喜欢 URL 中的空格:
var escapedBundlePath = Uri.EscapeUriString(NSBundle.MainBundle.BundlePath);
var myUrl = "Path/To/File/Test.html?var1=hello&var2=world";
var nsUrl = new NSUrl(Path.Combine(escapedBundlePath, myUrl));
WebView.LoadRequest(new NSUrlRequest(nsUrl));
关于c# - 将带有 QueryString 的 URL 传递给 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34066575/