Xamarin Android-使用CookieContainer和javascript加载Web视图

Xamarin Android-使用CookieContainer和javascript加载Web视图,javascript,android,webview,xamarin,Javascript,Android,Webview,Xamarin,我正在尝试使用与我的应用程序中的其他HttpWebRequests相同的sessionId加载一个WebView,页面上有需要运行的javascript 我正在设置_webView.JaveScriptEnabled=true 当我使用LoadUrl加载页面时,javascript会运行,但发送的ASP.NET_SessionId与我的其他HttpWebRequests发送的会话id不同,并且我无法设置CookieContainer: _LoadUrl(apiBase+“/App/Index”)

我正在尝试使用与我的应用程序中的其他HttpWebRequests相同的sessionId加载一个WebView,页面上有需要运行的javascript

我正在设置_webView.JaveScriptEnabled=true

当我使用LoadUrl加载页面时,javascript会运行,但发送的ASP.NET_SessionId与我的其他HttpWebRequests发送的会话id不同,并且我无法设置CookieContainer:

_LoadUrl(apiBase+“/App/Index”)

当我使用HttpWebRequest检索页面时,我可以设置CookieContainer并加载页面,但javascript不会运行:

var httpReq=(HttpWebRequest)HttpWebRequest.Create(新Uri(apiBase+“/App/Index”)
httpReq.CookieContainer=CookieContainer
var response=(HttpWebResponse)httpReq.GetResponse()
使用(StreamReader sr=new StreamReader(response.GetResponseStream())
{
var viewResult=;
_webView.LoadData(sr.ReadToEnd(),“text/html”,“UTF-8”);
}


如何在一个web调用中同时获得这两种行为?

我找到了,我需要更改
_webView.LoadData(sr.ReadToEnd(),“text/html”,“UTF-8”)

_webView.LoadDataWithBaseURL(apiBase,sr.ReadToEnd(),“text/html”,“UTF-8”,和“”)