小编AD.*_*Net的帖子

Web Api 2预检CORS对承载令牌的请求

我有一个带有AngularJS前端和Web Api 2后端的Web应用程序,它使用bearer-tokens进行身份验证.

一切都在FireFox和IE中很好,但对于Chrome,我的初始登录请求是SOMETIMES预先通过.

这是来自AngularJS服务的调用:

$ http.post(http://localhost:55483/token,data,{headers:{'Content-Type':'application/x-www-form-urlencoded'}}).success(function(response){...});

预检请求因"Allow-Access-Control-Origin"错误而被踢回.

但是,如果我再次单击"登录"按钮(从而重新发送上述请求),一切都很顺利.

关于如何防止/陷阱/处理这个的任何想法?

PS:我使用LOC

context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
Run Code Online (Sandbox Code Playgroud)

ApplicationOAuthProvider.cs文件中将CORS allow-header放在/ Token请求上,这在IE,FireFox和Chrome中都可以正常工作.

cors angularjs asp.net-web-api2

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

从Obj C转换为C#

我试图将这段代码转换为C#,代码来自Apple的文档

NSDictionary* info = [aNotification userInfo];

CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; 

UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);

scrollView.contentInset = contentInsets;

scrollView.scrollIndicatorInsets = contentInsets;

CGRect aRect = self.view.frame;

aRect.size.height -= kbSize.height;

if (!CGRectContainsPoint(aRect, activeField.frame.origin) ) {

    CGPoint scrollPoint = CGPointMake(0.0, activeField.frame.origin.y-kbSize.height);

    [scrollView setContentOffset:scrollPoint animated:YES];
Run Code Online (Sandbox Code Playgroud)

到目前为止,这是我的尝试,我陷入了CGRectValue.

                    NSDictionary info = n.UserInfo;

        SizeF kbSize = ((RectangleF)info[UIKeyboard.FrameBeginUserInfoKey]).Size;

        UIEdgeInsets contentInsets = new UIEdgeInsets(0.0f, 0.0f, kbSize.Height, 0.0f);

        this.uiScrollView.ContentInset = contentInsets;
        this.uiScrollView.ScrollIndicatorInsets = contentInsets;

        RectangleF aRect = this.View.Frame;

        aRect.Size.Height -= kbSize.Height;

        if(!aRect.Contains(_currentField.Frame))
        {
            PointF scrollPoint …
Run Code Online (Sandbox Code Playgroud)

.net c# objective-c xamarin.ios uikeyboard

8
推荐指数
2
解决办法
3709
查看次数

选择多个C#的组和总和?

我有一个传入的数组,每行有一个计数和一个字符串,表示一个或多个键由下划线分割.

对于每个键我想分组并总和总和,如果键出现在一行中总共5,每个项目由下划线分开,其总数增加5.

我只是想知道如何在linq中表示...

 class Owl
    {
        public int SpeciesCount { get; set; }
        public string BandIdentifier { get; set; }
    }

public class GoOwl
{
    public GoOwl(Owl[] owls)
    {
       //just making a list of test data to illustrate what would be coming in on the array
        var owlList = new List<Owl>();
        owlList.Add(new Owl { SpeciesCount = 2, BandIdentifier = "OWL1" });
        owlList.Add(new Owl { SpeciesCount = 1, BandIdentifier = "OWL1_OWL2_OWL3" });
        owlList.Add(new Owl { SpeciesCount = 2, BandIdentifier = "OWL3" …
Run Code Online (Sandbox Code Playgroud)

c# linq grouping concatenation

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

Monotouch和Azure移动服务

我看了一下github项目,但我有点迷茫.我试图编译解决方案,但得到错误,似乎有很多文件丢失.究竟应该添加哪些文件/项目以使天蓝色移动服务与新项目一起使用?

另外,鉴于移动服务的新变化,以上是否会起作用?可以在monotouch中使用便携式库吗?

请帮忙.提前致谢.

azure xamarin.ios azure-mobile-services

0
推荐指数
1
解决办法
238
查看次数