小编Rob*_*ous的帖子

CSS:如何使用calc(100% - 20px)来获得一个区域来填充除固定宽度元素以外的所有区域?

为复杂的头衔道歉.这是我的小提琴:

http://jsfiddle.net/PTSkR/152/

如果将结果窗格向外拖动更宽,则可以看到蓝色区域向上跳跃.他们应该总是在那里,填补边栏(宽度275px)没有的任何区域.我试着用这个:

width: calc(100%-275px);
Run Code Online (Sandbox Code Playgroud)

但它似乎没有做到这一点.知道我怎么能按预期工作吗?

HTML:

<div id="page-content" class="container-fluid page-host">
<div id="shell-row" class="row-fluid">
     <div id="sidebar" class="sidebar-nav span2">
     </div>
     <div id="browser-body" class="span10">
        <ul class="breadcrumb">
        </ul>
        <div id="container">
        </div>
     </div>       
</div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

    #page-content {
    padding: 0px;
    margin-top: 0px;
    height: 100% !important;
}
#shell-row {
    height: 100%;
}
#sidebar {
  font-family: "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
  background-color: #f0f0f0;
  height: 100%;
  width: 275px !important;
}

#browser-body {
  margin: 0px 0px 0px 0px !important;
    background-color: lightblue;
    width: …
Run Code Online (Sandbox Code Playgroud)

css html5 css3 twitter-bootstrap

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

SignalR - 将参数发送到OnConnected?

我有以下JS工作:

var chat = $.connection.appHub;
Run Code Online (Sandbox Code Playgroud)

我的应用程序有一个集线器,AppHub可处理两种类型的通知 - ChatOther.我正在使用单个集线器,因为我需要始终访问所有连接.

我需要能够OnConnected通过以下内容告诉它是哪种类型:

[Authorize]
public class AppHub : Hub {
    private readonly static ConnectionMapping<string> _chatConnections =
        new ConnectionMapping<string>();
    private readonly static ConnectionMapping<string> _navbarConnections =
        new ConnectionMapping<string>();
    public override Task OnConnected(bool isChat) { // here
        string user = Context.User.Identity.Name;
        if (isChat){
            _chatConnections.Add(user, Context.ConnectionId);
            _navbarConnections.Add(user, Context.ConnectionId);
        } else{
            _navbarConnections.Add(user, Context.ConnectionId);
        }  
    }
}
Run Code Online (Sandbox Code Playgroud)

用法最好是这样的:

var chat = $.connection.appHub(true);
Run Code Online (Sandbox Code Playgroud)

如何从javascript将该参数传递到集线器?

更新:

发信息:

 // will have another for OtherMessage
 public void …
Run Code Online (Sandbox Code Playgroud)

signalr signalr-hub

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

WebAPI + Forms Authentication + SimpleMembershipProvider使用WindowsIdentity时不应该使用

我做了什么

我正在构建一个REST-ish WebAPI应用程序.我正在尝试在此处实现表单身份验证,因此客户端可以允许用户从其浏览器登录/注册/注销.我正在使用simpleMembership,用户存储在我的应用程序的simpleMembership数据库表中.作为第一步,我在AccountsController中实现了一个登录方法:

    [System.Web.Http.HttpPost]
    public HttpResponseMessage LogIn(LoginModel model)
    {
        if (ModelState.IsValid)
        {
            if (User.Identity.IsAuthenticated)
            {
                return Request.CreateResponse(HttpStatusCode.Conflict, "already logged in.");
            }
            if (WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                //TODO: look up by id, not by name
                var userProfile = _service.GetUser(WebSecurity.GetUserId(model.UserName));
                return Request.CreateResponse(HttpStatusCode.OK, userProfile);
            }
            else
            {
                return new HttpResponseMessage(HttpStatusCode.Unauthorized);
            }
        }

        // If we got this far, something failed
        return new HttpResponseMessage(HttpStatusCode.InternalServerError);
    }
Run Code Online (Sandbox Code Playgroud)

问题

这是发生了什么:

  1. 我设定了一个断点if (User.Identity.IsAuthenticated).
  2. 使用像POSTMan或Fiddler这样的东西,我尝试使用一些伪造的凭据登录.
  3. 正如预期的那样,我点击断点并为IsAuthenticated获得"False".
  4. 我跳到下一个'if',并按预期尝试LogIn失败.
  5. else命中语句中的代码被命中,但一旦返回,1)我的断点再次被击中,2)主体被设置为我的Windows身份.两者都是意料之外的,我正试图弄清楚如何纠正它.

在此输入图像描述

预期的行为

  • 该方法只返回401 Unauthorized,因为我的应用程序数据库中不存在伪造用户.

组态

我 …

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

13
推荐指数
1
解决办法
7423
查看次数

MVC捆绑 - 无法加载资源

可能是什么导致了这个?我正在使用DurandalJS项目,该项目可以在本地构建和运行.当我尝试部署到Azure网站时,该应用程序发布但在浏览器中失败:

无法加载资源:服务器响应状态为404(未找到) http://appsite.azurewebsites.net/Scripts/vendor.js?v=KJCisWMhJYMzhLi_jWQXizLj9vHeNGfm_1c-uTOfBOM1

我没有定制任何捆绑.

我的捆绑配置:

public class BundleConfig
{
    // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

        bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                    "~/Content/themes/base/jquery.ui.core.css",
                    "~/Content/themes/base/jquery.ui.resizable.css",
                    "~/Content/themes/base/jquery.ui.selectable.css",
                    "~/Content/themes/base/jquery.ui.accordion.css",
                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                    "~/Content/themes/base/jquery.ui.button.css",
                    "~/Content/themes/base/jquery.ui.dialog.css", …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc azure bundler azure-web-sites durandal

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

使用SQL进行GROUP BY WEEK

我有以下内容:

http://sqlfiddle.com/#!6/226ae/1

我现在尝试在一年中的每个星期添加一行,并相应地过滤联系人.CONTACTS有一个datetime列.新表格如下:

        Status 1    Status 2    Status 3
Week 1      3          4           2
Week 2      1          5           3
Week 3      2          2           4
Run Code Online (Sandbox Code Playgroud)

我认为需要使用DATEADD,但是我在如何开始更改查询方面感到茫然.

我知道MySQL有一个GROUP BY WEEK命令,但我不认为SQL有一个等价的.实现这一目标的最佳方法是什么?

sql t-sql

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

多语句事务中不允许CREATE DATABASE语句

我正在尝试构建一个快速测试,每次运行时删除并重新创建数据库.我有以下内容:

[TestClass]
public class PocoTest
{
    private TransactionScope _transactionScope;
    private ProjectDataSource _dataSource; 
    private Repository _repository = new Repository();
    private const string _cstring = "Data Source=.;Initial Catalog=test_db;Trusted_Connection=True";

    [TestInitialize]
    public virtual void TestInitialize()
    {
        _dataSource = new ProjectDataSource(_cstring);
        _dataSource.Database.Delete();
        _dataSource.Database.CreateIfNotExists();
        _transactionScope = new TransactionScope();
    }
    [TestMethod]
    public void TestBasicOperations()
    {                
        var item = _repository.AddItem(new Item(){Details = "Test Item"});
        //  AddItem makes a call through the data context to add a set and then calls datacontext.SaveChanges()
    }


    [TestCleanup]
    public void TestCleanup()
    {
        // …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework

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

可以在迭代时修改List吗?

我有以下内容:

foreach (var depthCard in depthCards)
{
    var card = InternalGetCard(db, depthCard.CardId);
    var set = InternalGetSet(db, (int)card.ParentSetId);
    var depthArray = InternalGetDepthArrayForCard(db, set.SetId);
    foreach (var cardToUpdate in set.Cards)
    {
        // do stuff
        SaveChanges(db);
        depthCards.Remove(depthCardToUpdate); // since I already took care of it here, remove from depthCards
    }
}
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为我正在循环中修改集合.我的问题是......是否有某种类型的集合允许这种类型的访问?

我不想ToList()depthCards,因为我已经有他们,我修改该列表作为我迭代.可能吗?

.net c#

11
推荐指数
2
解决办法
9262
查看次数

Azure:工作者角色循环"回收"

我目前正在开发一个Azure项目,该项目在本地100%使用模拟器资源.我现在正在尝试部署一个辅助角色,但我遇到了一个我不确定如何排除故障的问题.

在Azure门户中部署辅助角色后,这两个实例不断循环"循环".

我可以尝试RDP进入这个角色,但是在连接关闭之前我只有大约一分钟的时间环顾四周,我假设由于回收.

经过一番搜索,似乎这不是一个超常见的问题.是否有一些微不足道的东西我可以忽视这可能导致这个问题?您将如何解决此问题?感谢您的时间 :)

azure azure-storage azure-storage-blobs azure-worker-roles azure-table-storage

9
推荐指数
2
解决办法
6314
查看次数

如何从HttpResponseMessage获取对象?

我有一个Post方法返回一个HttpResponseMessage:

HttpResponseMessage response = 
    Request.CreateResponse(HttpStatusCode.Created, updatedItemDto);
Run Code Online (Sandbox Code Playgroud)

我正在为此编写一些测试,并希望从HttpResponseMessage(特别是ItemId)获取更新的项目.我尝试检查对象,它看起来像对象存在Response.Content,但我不知道如何从对象中获取它Content.

.net asp.net asp.net-mvc

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

当在视图中使用ko时,ko.applyBindings给出错误"ko未定义"

我的MVC布局中有以下内容(在底部):

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/knockout")
@Scripts.Render("~/bundles/viewmodels")
Run Code Online (Sandbox Code Playgroud)

我在Developer工具的Sources选项卡中看到了knockout加载.

在我的一个观点中,我必须做以下事情:

<script type="text/javascript">ko.applyBindings(@Html.Raw(Json.Encode(Model)));</script>
Run Code Online (Sandbox Code Playgroud)

但这给了我一个错误: ko is not defined

尽管遭遇淘汰赛,为什么会发生这种情况?

asp.net-mvc asp.net-mvc-3 knockout.js

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