小编Nes*_*hta的帖子

jQuery文件上传不会在IE9中发送文件

我只在IE <10中遇到这样的问题.我的消息来源:

$("input:file#upload-photo").fileupload({
    enctype: "multipart/form-data",
    url: $("input:file#upload-photo").attr("url"),
    autoUpload: true,
    send: function() {
        spinner.spin(target);
    },
    done: function (e, data) {
        spinner.spin(false);

        var errors = data.result.Errors;
        if (errors != null && errors.length > 0) {
            for (var i = 0; i < errors.length; i++) {
                var ul = $("<ul>").html("<li>" + errors[i] + "</li>");
                $('#upload_photo_errors').html(ul);
            }
        } else {
            $(".profile-photo").attr("src", data.result.Data.AvatarUrl);
        }
    },
    error: function() {
        spinner.spin(false);
    }
});
Run Code Online (Sandbox Code Playgroud)

调用'send'处理程序,'error'处理程序也是如此.

我在Fiddler中发现了我的请求.它没有Content-Type和任何数据:

POST http://172.20.40.45/site/api/Users/Avatar HTTP/1.1
X-Requested-With: XMLHttpRequest
Accept: */*
Referer: http://172.20.40.45/site/Profile/Edit
Accept-Language: ru
Accept-Encoding: …
Run Code Online (Sandbox Code Playgroud)

javascript jquery internet-explorer file-upload blueimp

12
推荐指数
1
解决办法
2万
查看次数

Owin Authentication.SignIn不工作

我尝试使用owin身份验证管理器来验证用户,但User.Identity.IsAuthenticated仍然是假的.

Startup.cs

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.MapSignalR();
    }
}
Run Code Online (Sandbox Code Playgroud)

Startup.Auth.cs

public partial class Startup
{
    public static Func<UserManager<ApplicationUser>> UserManagerFactory { get; set; }

    public Startup()
    {
        UserManagerFactory = () =>
        {
            var userManager = new UserManager<ApplicationUser>(new CustomUserStore());
            return userManager;
        };
    }

    public void ConfigureAuth(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
            LogoutPath = new PathString("/Account/LogOff"),
            ExpireTimeSpan = TimeSpan.FromDays(7)
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

身份验证操作的某些部分:

private async Task SignInAsync(ApplicationUser user, bool isPersistent) …
Run Code Online (Sandbox Code Playgroud)

c# authentication asp.net-mvc owin asp.net-identity

8
推荐指数
1
解决办法
6884
查看次数

Facebook使用外部承载令牌登录(MVC4 Web Api)

我正在尝试使用外部承载令牌实现Facebook登录.我在VS 2013中创建了新项目,并选择了个人用户帐户身份验证,例如http://www.alyp.net/web-api/overview/security/external-authentication-services.

我配置了facebook身份验证:

app.UseFacebookAuthentication(
            appId: "123[...]",
            appSecret: "123[...]");
Run Code Online (Sandbox Code Playgroud)

一切正常.

我的测试方法:

[OverrideAuthentication]
[HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)]
[Route("ExternalLogin2", Name = "ExternalLogin2")]
public async Task<IHttpActionResult> GetExternalLogin2()
{
    ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity);
    return Ok();
}
Run Code Online (Sandbox Code Playgroud)

我不明白[HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)]的工作原理.

我在fiddler中调用GET请求:

GET http://localhost:17353/api/Account/ExternalLogin2 HTTP/1.1
Authorization: Bearer [my facebook token]
Content-Length: 28
Host: localhost:17353
Run Code Online (Sandbox Code Playgroud)

但我收到401结果.

我必须做什么才能通过外部承载令牌进行身份验证?

authentication asp.net-mvc asp.net-web-api owin

7
推荐指数
1
解决办法
1427
查看次数

PushSharp不发送通知

我有一个简单的代码:

PushBroker pushBroker = new PushBroker();
string path = HttpContext.Current.Server.MapPath("~/" + AppSettings.CertificatePath);
var appleCert = File.ReadAllBytes(path);        
pushBroker.RegisterAppleService(
           new ApplePushChannelSettings(AppSettings.IsProductionPushNotificationServer,
                                        appleCert,
                                        AppSettings.CertificatePassword));

var notification = new AppleNotification().ForDeviceToken(deviceToken.TrimStart('<').TrimEnd('>'))
                                          .WithBadge(unviewedInvitationCount);

pushBroker.QueueNotification(notification);
Run Code Online (Sandbox Code Playgroud)

我尝试分别使用Sandbox和Production服务器的开发和生产sertificates.但什么都没发生.客户端能够获得推送通知.怎么了?提前致谢.

更新:

我订阅了这些活动.

OnNotificationFailed告诉我有关此错误的信息:

{APNS NotificationFailureException -> 5 : Invalid token size -> {"aps":{"badge":1}}}
Run Code Online (Sandbox Code Playgroud)

如果我将设备令牌包装到<...>中,我会收到另一个错误:

{APNS NotificationFailureException -> 8 : Invalid token -> {"aps":{"badge":1}}}
Run Code Online (Sandbox Code Playgroud)

c# push-notification apple-push-notifications pushsharp

7
推荐指数
1
解决办法
6604
查看次数