我有一个int数组作为Web用户控件的属性.如果可能,我想使用以下语法设置该属性内联:
<uc1:mycontrol runat="server" myintarray="1,2,3" />
这将在运行时失败,因为它将期望一个实际的int数组,但正在传递一个字符串.我可以创建myintarray一个字符串并在setter中解析它,但我想知道是否有更优雅的解决方案.
假设我有两个对象:文章和类别,两者之间有很多关系.为了这个例子,所有相关的类别都已添加到数据存储中.循环浏览包含文章编辑的数据时,需要保存类别关系信息.
我打算在类中使用该-setValue方法Article来设置如下的关系:
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    if([key isEqualToString:@"categories"]){
        NSLog(@"trying to set categories...");
    }
}
问题是value不是a Category,它只是一个包含类别标题的字符串(或字符串数组).我当然可以在这个方法中为每个类别进行查找并分配它,但是在一次处理大量文章时这似乎效率低下.另一种选择是填充所有可能类别的数组并只过滤,但我的问题是存储该数组的位置?它应该是一个类方法Article吗?有没有办法将额外的数据传递给-setValue方法?是否有另一个更好的选择来设定我没想到的关系?
谢谢你的帮助.
我使用Classic .NET AppPool在IIS的默认网站上运行Windows 2008 R2服务器和ASP.Net 2.0 Web应用程序.在下面我有一个使用ASP.NET v4.0集成管道AppPool运行MVC 3的虚拟应用程序.
应用程序池自动回收后,MVC虚拟应用程序经常出现故障.修复是手动回收ASP.NET 4.0 AppPool.我只需要回收一次,它总能解决问题.
我收到的应用程序错误似乎是程序集未正确加载时出现的错误.它们包括NullReferenceException与Object reference not set to an instance of an object对控制器和视图模型.
问题是我无法按需重现这个,以便正确调试问题.我原以为应用程序池回收的顺序可能是一个问题,因此我将Classic池设置为每晚凌晨1点重新启动,而集成池将在凌晨1:15重新启动.不幸的是,这没有帮助.
关于按需加载程序集的答案很有意思,但是我不确定为什么错误很少发生,而且看似随意.
有没有人知道我将如何能够不断重现问题和/或潜在的解决方案?谢谢.
更新以包含示例堆栈跟踪:
Exception information: 
    Exception type: NullReferenceException 
    Exception message: Object reference not set to an instance of an object.
   at Bookstore.Controllers.BooksController.<>c__DisplayClass78.<Details>b__76(Grade g)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Bookstore.Controllers.BooksController.Details(String booktitle)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at …我有一个Owin Identity应用程序和另一个在虚拟目录中设置的应用程序.虚拟应用程序使用传统的表单身份验证进行设置,并且两个Web.configs都具有相同的<machineKey>设置.我可以使用Identity应用程序登录,并可以看到生成的cookie.但是,当我尝试访问虚拟应用程序时,它说我没有通过身份验证.
在Identity应用程序中,我有以下设置:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
  AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
  LoginPath = new PathString("/login.aspx"),
  Provider = new CookieAuthenticationProvider
  {
    // Enables the application to validate the security stamp when the user logs in.
    // This is a security feature which is used when you change a password or add an external login to your account.  
    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
      validateInterval: TimeSpan.FromMinutes(30),
      regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
  }
});
在虚拟应用程序中,我的授权设置如下:
<authorization>
      <deny users="?" />
</authorization>
是否有任何指针让虚拟应用程序识别Identity设置的cookie?
asp.net ×4
asp.net-mvc ×1
core-data ×1
cryptography ×1
iis ×1
iphone ×1
objective-c ×1
owin ×1
salt ×1
security ×1