簡體   English   中英

將帶有QueryString的URL傳遞給UIWebView

[英]Passing URL with QueryString to UIWebView

我遇到類似的問題: https : //forums.xamarin.com/discussion/6319/problem-with-webview-and-url

我使用UIWebView嘗試傳遞帶有查詢字符串的URL。 URI如下所示: "Content/Content/holder.html/?contentpath=/test.html"

沒有查詢字符串,文檔將正確顯示。 但是,使用querystring時,出現以下錯誤:
Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server."

似乎沒有分隔查詢字符串。
我已經閱讀了一些C解決方案,但是我無法在C#解決方案中反映出來。 尤其

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));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM