![](/img/trans.png)
[英]Asp.Net Core 2.1 SPA React Template with Windows Authentication
[英]Implementing windows auth with an ASP.NET Core SPA
我已经在ASP.NET Core中使用Aurelia开发了SPA应用程序。 现在,在我的startup.cs文件中,我的configure方法中包含以下内容:
app.UseIISPlatformHandler();
app.UseApplicationInsightsExceptionTelemetry();
app.UseStaticFiles();
app.UseFileServer(new FileServerOptions
{
EnableDefaultFiles = true,
EnableDirectoryBrowsing = false
});
据我了解,此app.UseStaticFiles()
指示该应用在wwwroot文件夹中查找default.html
或index.html
。 我想以某种方式做一些业务逻辑来检查用户的Windows用户名,并通过我们的业务逻辑运行它来检查/验证它。 有没有一种方法可以让我创建一个家庭控制器,并让该控制器在执行适当的检查后甚至从startup.cs文件中完成该操作,以返回wwwroot / index.html文件? 如果是这样,您能否详细说明如何做。
我认为最好的解决方案是将文件插入到View文件夹中。 然后添加到启动
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
在索引方法中,将您的业务逻辑用于检查验证。
如果您对用于自动登录用户的良好解决方案感兴趣,可以查看: https ://docs.asp.net/zh/latest/security/authentication/identity.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.