我有一个带有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中都可以正常工作.
我试图将这段代码转换为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) 我有一个传入的数组,每行有一个计数和一个字符串,表示一个或多个键由下划线分割.
对于每个键我想分组并总和总和,如果键出现在一行中总共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# ×2
xamarin.ios ×2
.net ×1
angularjs ×1
azure ×1
cors ×1
grouping ×1
linq ×1
objective-c ×1
uikeyboard ×1