我正在构建一个Web应用程序,它将使用DotNetOpenAuth提供api和授权服务.我发现这个例子就如何使用已经存在的服务供应商授权,但我想就如何落实它可以创建令牌,坚持他们做评估服务提供商的例子.我可以下载任何优秀的文章或样本提供商吗?
我正在使用像这样的CustomValidationAttribute
[CustomValidation(typeof(MyValidator),"Validate",ErrorMessage = "Foo")]
Run Code Online (Sandbox Code Playgroud)
我的验证器包含此代码
Run Code Online (Sandbox Code Playgroud)public class MyValidator { public static ValidationResult Validate(TestProperty testProperty, ValidationContext validationContext) { if (string.IsNullOrEmpty(testProperty.Name)) { return new ValidationResult(""); <-- how can I get the error message from the custom validation attribute? } return ValidationResult.Success; } }
那么如何从自定义验证属性中获取错误消息?
c# asp.net-mvc customvalidator data-annotations asp.net-mvc-3
我有一个看起来像这样的简单类......
public class Item {
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual int ParentId { get; set; }
public virtual IList<Item> Children { get; private set; }
public Item() {
Children = new List<Item>();
}
}
Run Code Online (Sandbox Code Playgroud)
...其中Id是主键,ParentId是外键.当我运行此代码时,我得到无效的对象名称'ItemToItem'.例外,我无法弄清楚出了什么问题?我似乎NHibernate试图从名为ItemToItem的表中选择或类似的东西?
我的区域有两条路线,一条是自定义路线,一条是默认后备路线,见下文
var dashboardRoute = new DashboardRoute(
ObjectFactory.GetInstance<PathResolver>(),
ObjectFactory.GetInstance<VirtualPathResolver>(),
null);
context.Routes.Add(dashboardRoute);
context.Routes.MapRoute(
"Dashboard_Default", // Route name
"dashboard/{controller}/{action}/{id}", // URL with parameters
new { controller = "pages", action = "index", id = UrlParameter.Optional, area = "Dashboard" } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
当我使用context.Routes.Add/MapRoute添加两个路由时,最后一个路由不起作用,但是当我在最后一个路由上使用context.MapRoute时它工作但我的自定义路由中的GetVirtualPath不用于actionlinks.我认为MapRoute只是context.Routes.Add的扩展?调试路由的最佳方法是什么?我已经使用了Phil Haacks路由调试,但它不适用于我的自定义路由,有没有其他方法来调试路由?
我真的需要一些帮助.我的仪表板区域中的路线注册如下所示 -
var dashboardRoute = new PagesRoute(
ObjectFactory.GetInstance<PathResolver>(),
ObjectFactory.GetInstance<VirtualPathResolver>(),
null);
context.Routes.Add("Dashboard", dashboardRoute);
context.MapRoute(
"Dashboard_default",
"dashboard/{controller}/{action}/{id}",
new { controller = "dashboard", action = "index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
PageRoute是一个自定义路线,你可以在这里找到代码http://bit.ly/er6HPn 这条路线有效,这样的链接很好用Html.ActionLink("管理角色","manageroles","帐户")但是当我有一个应该使用我的自定义路由的链接,如Html.ActionLink(page.MetaData.Name,"edit","pages",new {document = page},null)时,结果为http:// stormbreaker. local/dashboard/pages/edit?document …
我有一个虚拟路径提供程序,它从我的虚拟文件系统提供静态文件,是否可以通过我的虚拟路径提供程序将IIS配置为服务器静态文件,还是需要创建自定义静态文件处理程序?
这个问题的背景是基于我正在开发的虚拟文件系统.我正在使用的概念是针对不同类型的存储类型的虚拟路径提供程序,即本地文件系统,dropbox和amazon s3.我的虚拟文件基类如下所示:
public abstract class CommonVirtualFile : VirtualFile {
public virtual string Url {
get { throw new NotImplementedException(); }
}
public virtual string LocalPath {
get { throw new NotImplementedException(); }
}
public override Stream Open() {
throw new NotImplementedException();
}
public virtual Stream Open(FileMode fileMode) {
throw new NotImplementedException();
}
protected CommonVirtualFile(string virtualPath) : base(virtualPath) { }
}
Run Code Online (Sandbox Code Playgroud)
第二个Open方法的实现就是我的问题.如果我们查看本地文件系统的实现,即在磁盘上保存文件,它看起来像这样:
public override Stream Open(FileMode fileMode) {
return new FileStream("The_Path_To_The_File_On_Disk"), fileMode);
}
Run Code Online (Sandbox Code Playgroud)
如果我想在本地文件系统上保存文件,这将看起来像这样:
const string virtualPath = "/assets/newFile.txt";
var file …Run Code Online (Sandbox Code Playgroud) 我WebActivator.PreApplicationStartMethod在我目前的项目中使用但似乎OwinStartupAttribute可以做同样的工作?这是正确使用的OwinStartupAttribute吗?
我需要运行的应用程序开始之前的代码和到现在为止我已经使用WebActivator要做到这一点,但如果我理解正确的OwinStartupAttribute是更适合于这一点,但对我来说,问题是,它运行后Application_Start在Global.asax,这是正确的或我可以配置它运行预应用程序启动?
我正在考虑使用 aDictionary<string, object>通过字符串键查找值。据我所知,键越长,在字典中查找所需的时间就越长。我的密钥可能会很长,例如/page-1/page-2/page-3/page-4......等等,其中每个名称本身都可能很长。
在字典中使用长字符串键时,性能会受到什么影响?是什么机制导致了这些成本?
c# ×7
asp.net-mvc ×3
owin ×2
amazon-s3 ×1
iis ×1
iis-7 ×1
ipv6 ×1
oauth-2.0 ×1
performance ×1
webactivator ×1