设置(使用MVC 4)
public class MyAuthorizeAttribute : AuthorizeAttribute {
protected override bool AuthorizeCore(HttpContextBase httpContext) {
var isAuthorised = base.AuthorizeCore(httpContext);
if(isAuthorised) {
// retrieve authentication ticket from cookie and
// create custome principal and attach to
// httpContext.User
}
return isAuthorised;
}
}
Run Code Online (Sandbox Code Playgroud)
Gloabl.asax.cs:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new MyAuthorizeAttribute());
}
Run Code Online (Sandbox Code Playgroud)
HomeController.cs:
using System.Web.Mvc;
public class HomeController : Controller
{
[AllowAnonymous]
public ActionResult Index()
{
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
问题
对主页的调用会强制加载登录页面.
题
当HomeController.Index()动作用[AllowAnonymous]修饰时,为什么ASP会将我重定向到登录视图?
我正在使用这篇文章作为参考
asp.net security authentication asp.net-mvc forms-authentication
建立 :
我有一个包含div,意思是可滚动.这是我的jquery ui tab div的容器.
问题:
当我在IE8中滚动容器时,它会滚动其中的其他内容,但jquery UI选项卡被固定,就像position = fixed一样.在FF中工作正常.欢迎任何帮助.非常感谢
CSS:
#content {
overflow:auto;
margin: 1px;
height: 700px;
}
div.content-container {
border: solid 1px #C8C8C8;
padding:10px;
background-color: #F5F3E5;
margin: 1px 2px 10px 1px;
}
Run Code Online (Sandbox Code Playgroud)
JS:
$('#tabs').tabs();
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="content">
<div class="content-container">
<div id="tabs">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 建立:
使用NuGet,我的UnitTest项目引用了Ninject v2.2.1.4
我的Web项目引用了Ninject v3.0.0.15,Ninject.MVC3和Ninject.Web.Common
问题:
随着win explorer在我的web项目的bin文件夹中打开,我构建了我的解决方案,我可以看到Ninject v2.2.1.4被复制到我的web项目的bin目录中.然后被Ninject v3.0.0.15取代.
当我点击F5进行调试时,Ninject.dll v3.0.0.15被Ninject v2.2.1.4取代,导致以下错误:
无法加载文件或程序集'Ninject,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = c7192dc5380945e7'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)
是什么赋予了?
我有以下javascript:
var MyObject = (function() {
function Setup(args) {
this.prop1 = args.x;
this.prop2 = args.y
this.prop3 = this.prop1 + this.prop2;
this.Create = function() {
return 'a' + helperFunc();
}
function helperFunc() {
return this.prop3;
}
}
return {
init : function(args) {
var setup = new Setup(args);
setup.Create();
}
}
})();
$(function() {
MyObject.init(someArgs);
});
Run Code Online (Sandbox Code Playgroud)
我的对象构建方法是一种好的做法吗?
我undefined试图访问时进入helperFunc this.prop3.
我也尝试分配this.prop1 + this.prop2一个局部变量并使用函数来返回这个值,如下所示:
function Setup(args) {
var total;
this.prop1 = args.x;
this.prop2 = args.y
total = this.prop1 …Run Code Online (Sandbox Code Playgroud)为了简单起见,我只是不明白为什么这不起作用.
我需要在文档的正文中附加一个div,然后再将相同div的副本附加但是隐藏,然后是另一个div,然后是另一个div的副本,但是隐藏了,依此类推......
$.each(myObj.items, function(i, item) {
// createItem simply finds an html fragment in the document,
// clones it and returns it
var $i = createItem(item);
// add a div first that clears floats - this is needed before every item
$('body').append('<div class="clear"/>');
// append a clone of the html fragment
$('body').append($i.clone());
// add another div that clears floats
$('body').append('<div class="clear"/>');
// append a clone of the html fragment but hide it
$('body').append($i.clone().addClass('hidden'));
});
Run Code Online (Sandbox Code Playgroud)
我期待:
<body>
<div class="clear"/>
<div class="item">item</div> …Run Code Online (Sandbox Code Playgroud) 我有一个具有偶数行的表.
奇数行是可见的,并且其中包含删除按钮,甚至隐藏行.
删除应删除一对,奇数行和隐藏偶数行.
以下仅删除奇数行.如何删除奇数行和下一个兄弟?
$('deleteButton').click(function() {
var $tr = $(this).closest('tr');
$tr.remove().next('tr').remove();
});
Run Code Online (Sandbox Code Playgroud)
非常感谢
问题:
当在嵌套在使用knockout with数据绑定的元素下的jQuery对话框上使用时,select2 jQuery插件不起作用.删除with绑定,select2工作正常.如果with绑定到嵌套属性,则它将停止工作.
背景:
因此,我必须在3小时内努力争取让select2在jQuery对话框表单上工作....讨论关于这个谚语错误树的问题,我认为它纯粹是jQuery对话框和select2.它可能从一开始就_allowInteraction修复了.直到我把问题直接解决为简单的步骤,并且因为开始显露自己.问题在于with绑定.
放弃
当我为阻止jsFiddle的asinine公司工作时道歉.此外,由于实际模型非常大,我为了说明目的而细分了我的实现.
// models
function Department() {
this.name = ko.observable('dept1');
this.selectedTeam = ko.observable( new Team() );
}
function Team() {
this.name = ko.observable('team1');
}
function MainModel() {
this.department = new Department();
this.showTeam = function() {
$('#addTeamDialog').dialog('open');
};
}
// setup
ko.applyBindings( new MainModel() );
$('#addTeamDialog').dialog({
// fix allow select2 to work on the jq dialog
_allowInteraction: function (event) {
return !!$(event.target).is(".select2-input") || this._super(event);
}
}); …Run Code Online (Sandbox Code Playgroud)在Knockout中有一种干净的方式来显示我的视图模型中的布尔属性,以显示"是"或"否"而不是真/假.有时属性是未定义的,所以这也应该显示否.
目前使用:
<td data-bind="text: isAvailable ? 'Yes' : 'No'"></td>
Run Code Online (Sandbox Code Playgroud)
一定是更好的方式.