小编Chr*_*ins的帖子

RestSharp - 授权标头未涉及WCF REST服务

我试图通过基于身份验证的HTTPS调用本地托管的WCF REST服务.

这是有效的,授权标题通过很好,所有人都很高兴:

ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertficate;
var request = (HttpWebRequest)WebRequest.Create("https://localhost/MyService/MyService.svc/");
request.Method = "GET";
request.ContentType = "application/json";
request.Headers.Add(
  System.Net.HttpRequestHeader.Authorization,
  "Basic " + this.EncodeBasicAuthenticationCredentials("UserA", "123"));

WebResponse webResponse = request.GetResponse();
using (Stream webStream = webResponse.GetResponseStream())
{
    if (webStream != null)
    {
        using (StreamReader responseReader = new StreamReader(webStream))
        {
            string response = responseReader.ReadToEnd();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用RestSharp时,Authorization标头永远不会通过请求:

ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertficate;

var credentials = this.EncodeBasicAuthenticationCredentials("UserA", "123");

var client = new RestSharp.RestClient("https://localhost/MyService/MyService.svc/");   
var restRq = new RestSharp.RestRequest("/");
restRq.Method = Method.GET;
restRq.RootElement = "/";
restRq.AddHeader("Authorization", "Basic " …
Run Code Online (Sandbox Code Playgroud)

c# rest restful-authentication restsharp

18
推荐指数
3
解决办法
3万
查看次数

提琴手会话对象文档

在哪里可以找到有关Fiddler.Session对象的属性和方法的任何文档?我正在Fiddler中创建一些自定义规则(js)以进行故障排除.

fiddler

6
推荐指数
1
解决办法
3070
查看次数

找不到Mono Droid onClick事件

我有以下布局:

<Button android:id="@+id/MyButton"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/Hello"
    android:clickable="true"
    android:onClick="Foo"
/>
Run Code Online (Sandbox Code Playgroud)

这在我的活动中:

[Activity(Label = "LayoutTest", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        SetContentView(Resource.Layout.Main);
    }

    public void Foo(View v)
    {
        Toast.MakeText(v.Context, "Bar", ToastLength.Long).Show();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在模拟器中调试此应用程序时,当我单击MyButton时,应用程序崩溃,并在日志中显示以下摘录:

E/AndroidRuntime(  507): FATAL EXCEPTION: main
E/AndroidRuntime(  507): java.lang.IllegalStateException: Could not find a method    Foo(View) in the activity class helloworld.Activity1 for onClick handler on view class android.widget.Button with id 'MyButton'
E/AndroidRuntime(  507):    at android.view.View$1.onClick(View.java:2059)
E/AndroidRuntime(  507): …
Run Code Online (Sandbox Code Playgroud)

c# mono android xamarin.android

5
推荐指数
2
解决办法
1842
查看次数