Thinktecture.IdentityManager替代ASP.NET WebSite管理工具

In ASP.NET 2005 (v2 timeframe) there was a web-based tool called ASP.NET Website Administration tool that folks could use the edit users and generally administer the ASP.NET Membership database. This useful tool was removed in 2012 and is still missed.

在ASP.NET 2005(第2版时间框架)中,有一个基于Web的工具,称为ASP.NET网站管理工具,人们可以使用编辑用户并通常管理ASP.NET成员资格数据库。 这个有用的工具于2012年被删除,至今仍被遗漏。

Since then, ASP.NET has introduced ASP.NET Identity and community member Brock Allen created IdentityReboot with some significant improvements and extensions. Brock Allen and Dominick Baier have gone even further and created Thinktecture IdentityManager. It's the beginnings of a nice bootstrapped replacement for the missing ASP.NET Website Administration Tool. It's nicely factored and supports both ASP.NET Identity and their alternative called MembershipReboot.

从那时起,ASP.NET引入了ASP.NET Identity ,社区成员Brock Allen创建了IdentityReboot,并进行了一些重大改进和扩展。 Brock Allen和Dominick Baier走得更远,创建了Thinktecture IdentityManager 。 这是对缺少的ASP.NET网站管理工具进行很好的引导替换的开始。 它经过很好的分解,并支持ASP.NET Identity和它们的替代方案MembershipReboot

I cloned Thinktecture.IdentityManager and ran it under Visual Studio 2013.2. It's nice when projects just clone cleanly and build. You'd be surprised how often that's not the case.

我克隆了Thinktecture.IdentityManager并在Visual Studio 2013.2下运行它。 当项目只是干净地克隆并构建时,这很好。 您会惊奇地发现事实并非如此。

Thinktecture.IdentityManager plugs into the ASP.NET middleware pipeline, so switching the sample host to use ASP.NET Identity rather than their alternative MembershipReboot was as easy as commenting out a line and adding a line as seen below.

Thinktecture.IdentityManager插入了ASP.NET中间件管道,因此,将示例主机切换为使用ASP.NET Identity而不是替代的MembershipReboot就像注释一行并添加一行一样容易,如下所示。

public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseIdentityManager(new IdentityManagerConfiguration()
{
//UserManagerFactory = Thinktecture.IdentityManager.MembershipReboot.UserManagerFactory.Create
UserManagerFactory = Thinktecture.IdentityManager.AspNetIdentity.UserManagerFactory.Create
});
}
}

Just run it and you'll get a nice Bootstrapped interface for creating, editing, and deleting users from your Identity database.

只需运行它,您将获得一个不错的Bootstrapped界面,用于从Identity数据库创建,编辑和删除用户。

Here you can see those same users in the SQL database that ASP.NET Identity uses.

在这里,您可以在ASP.NET Identity使用SQL数据库中看到相同的用户。

The whole application is written as a Single Page Application with an ASP.NET Web API handling the backend with Angular.js on the frontend.. You could run this application as it's own site and lock it down, of course, or host it within your existing website at something like /admin.

整个应用程序被编写为具有ASP.NET Web API的单页应用程序,该ASP.NET Web API通过前端的Angular.js处理后端。您可以将其作为自己的网站运行,并锁定它,或者将其托管在内部您现有的网站,例如/ admin。

服务嵌入式资产 (Serving Embedded Assets)

Unrelated to the core functionality of Thinktecture.IdentityManager, one cool piece of functionality worth noting is how they are storing the HTML, CSS and other resources as embedded resources inside the Thinktecture.IndeityManager.Core assembly. This is not something you'd necessarily want to do yourself, but considering that they've got a nice embedded "manager" that they'll want to plug into other websites easily without causing issues with file dependencies, it's quite clever.

Thinktecture.IdentityManager的核心功能无关,值得注意的一项很酷的功能是它们如何将HTML,CSS和其他资源作为嵌入式资源存储在Thinktecture.IndeityManager.Core程序集中。 这并不是您一定要自己做的事情,但是考虑到他们有一个不错的嵌入式“管理器”,他们希望可以轻松地将其插入其他网站而不会引起文件依赖性问题,这非常聪明。

Here's the static page controller:

这是静态页面控制器:

public class PageController : ApiController
{
[Route("")]
[HttpGet]
public IHttpActionResult Index()
{
return new EmbeddedHtmlResult(Request, "Thinktecture.IdentityManager.Core.Assets.Templates.index.html");
}
}

Then later in EmbeddedHtmlResult:

然后稍后在EmbeddedHtmlResult中:

public static HttpResponseMessage GetResponseMessage(HttpRequestMessage request, string name)
{
var root = request.GetRequestContext().VirtualPathRoot;
var html = AssetManager.LoadResourceString(name);
return new HttpResponseMessage()
{
Content = new StringContent(html, Encoding.UTF8, "text/html")
};
}

Then later, all the CSS and JS are handled by the ".UseFileServer()" extension from Microsoft.Owin.StaticFiles, and then Microsoft.Owin.FileSystems handles the mapping the whole of the /assets URI space over all the resources

然后,稍后,所有CSS和JS都由Microsoft.Owin.StaticFiles的“ .UseFileServer()”扩展名处理,然后Microsoft.Owin.FileSystems处理所有资源上整个/ assets URI空间的映射

app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString("/assets"),
FileSystem = new EmbeddedResourceFileSystem(typeof(AppBuilderExtensions).Assembly, "Thinktecture.IdentityManager.Core.Assets")
});
app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString("/assets/libs/fonts"),
FileSystem = new EmbeddedResourceFileSystem(typeof(AppBuilderExtensions).Assembly, "Thinktecture.IdentityManager.Core.Assets.Content.fonts")
});

It's nice and clean, and a cool reminder about what you can do with a nicely factored system and a decent middleware pipeline.

它很干净,很酷,它提醒您使用一个很好的分解系统和一个不错的中间件管道可以做什么。

美好的未来 (A bright future)

If you've got a ASP.NET system and are looking for a flexible and simple web-based administration tool for your Identity system, you should totally check out Thinktecture.IdentityManager. It looks like the team is gearing up for the possible release of this project as NuGet, so may have that to look forward to as well!

如果您拥有ASP.NET系统,并且正在为Identity系统寻找一种灵活,简单的基于Web的管理工具,则应完全查看Thinktecture.IdentityManager 。 看起来团队正在为NuGet这个项目的可能发布做准备,所以可能也有期待!

Remember that when people create cool projects like this, they are often doing this as volunteers out of the kindness of their hearts. They are often looking for feedback and comments, sure, but also validation of their idea as well as help. Open source help can come in the form of Pull Requests, Bugs and Issues, Documentation, Build Servers, and more. Head over and "star" the GitHub Thinktecture.IdentityManager project, and check it out!

请记住,当人们创建像这样的很棒的项目时,他们常常是出于自愿而做志愿者。 当然,他们经常在寻找反馈和评论,同时也在寻求他们的想法和帮助。 开源帮助可以采用“拉取请求”,“错误和问题”,“文档”,“构建服务器”等形式。 头顶并“标记” GitHub Thinktecture.IdentityManager项目,然后签出!

相关链接 (Related Links)

翻译自: https://www.hanselman.com/blog/thinktectureidentitymanager-as-a-replacement-for-the-aspnet-website-administration-tool

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值