我有一个运行缓慢的查询(在大约100循环中需要5-10秒)并且不知道为什么.它只是查询对象列表......非常感谢您的帮助!
我基本上是在查询已分配给特定经理的计划表.它必须来自指定的移位周或下周的前2天或前一周的最后2天.
我之前尝试过计算.AddDays,但没有帮助.当我进行性能测试时,它突出显示了下面的"from"语句.
List<Schedule> _schedule = Schedule.GetAll();
List<Shift> _shifts = Shift.GetAll();
// Then later...
List<Schedule> filteredSchedule = (from sch in _schedule
from s in _shifts
where
**sch.ShiftID == s.ShiftID
& (sch.ManagerID == 1 | sch.ManagerID == 2 | sch.ManagerID == 3)
& ((s.ScheduleWeek == shift.ScheduleWeek)
| (s.ScheduleWeek == shift.ScheduleWeek.AddDays(7)
& (s.DayOfWeek == 1 | s.Code == 2))
| (sch.ScheduleWeek == shift.ScheduleWeek.AddDays(-7)
& (s.DayOfWeek == 5 | s.Code == 6)))**
select sch)
.OrderBy(sch => sch.ScheduleWeek)
.ThenBy(sch => sch.DayOfWeek)
.ToList();
Run Code Online (Sandbox Code Playgroud) 我真的被困在这一个......
基本上,我正在使用IIS的URLRewrite插件尝试使用SSL创建2个页面.但我还需要强制所有其他页面到HTTP(叹气 - 不要问).
但是如果我通过HTTP强制其他页面,那么当您查看SSL页面时,您将收到安全警告.我试图通过检查HTTP_REFERER是否是SSL页面来解决这个问题,然后让它通过SSL发送给该页面.这不起作用,因为如果有人单击SSL页面上的链接,那么它将保留在SSL上.
这甚至可能吗?......
到目前为止,这是我所得到的:
<rewrite>
<rules>
<rule name="Force HTTPS Login" stopProcessing="true">
<match url="(.+)login.aspx" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Force HTTPS Payments" stopProcessing="true">
<match url="(.+)payments.aspx" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Others Force HTTP" stopProcessing="true">
<match negate="true" url="((.+)login.aspx|(.+)payments.aspx)" />
<conditions>
<add input="{HTTPS}" pattern="^ON$" />
<add input="{HTTP_REFERER}" negate="true" pattern="(.+)login.aspx" />
<add input="{HTTP_REFERER}" negate="true" pattern="(.+)payments.aspx" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule> …Run Code Online (Sandbox Code Playgroud) 我决定清理这篇文章,并在ge.tt/3EwoZEd/v/0?c上发布了一个示例项目
已经花费了大约30个小时,但仍然无法弄明白...帮助真的很感激!
我有一个使用此代码的ASP.NET Web API解决方案:http://www.piotrwalat.net/basic-http-authentication-in-asp-net-web-api-using-message-handlers/来实现"Basic"使用消息处理程序在ASP.NET Web API中进行HTTP身份验证".我是IoC/DI的新手,我正试图让它与Castle Windsor合作.
我一直在尝试很多不同的东西但是我得到以下错误之一取决于我做错了什么:
以下是我的代码:
的Global.asax.cs:
private static IWindsorContainer _container;
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var config = (CustomErrorsSection)ConfigurationManager.GetSection("system.web/customErrors");
IncludeErrorDetailPolicy errorDetailPolicy;
switch (config.Mode)
{
case CustomErrorsMode.RemoteOnly:
errorDetailPolicy
= IncludeErrorDetailPolicy.LocalOnly;
break;
case CustomErrorsMode.On:
errorDetailPolicy
= IncludeErrorDetailPolicy.Never;
break;
case CustomErrorsMode.Off:
errorDetailPolicy
= IncludeErrorDetailPolicy.Always;
break;
default:
throw new ArgumentOutOfRangeException();
}
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = errorDetailPolicy;
ConfigureWindsor(GlobalConfiguration.Configuration);
GlobalConfiguration.Configuration.MessageHandlers.Add(new BasicAuthMessageHandler()
{
PrincipalProvider = _container.Resolve<IProvidePrincipal>()
});
}
public static …Run Code Online (Sandbox Code Playgroud) c# asp.net dependency-injection castle-windsor inversion-of-control