我有一个ASP.NET 5 dnxcore解决方案,其中包含一些项目来区分我的逻辑:
现在我使用DI在我的API控制器的构造函数中调用我的服务:
private readonly IMyService _myService;
public Controller(IMyService myservice){ _myService = myService; }
Run Code Online (Sandbox Code Playgroud)
我核心中的服务也通过构造函数注入获取存储库:
private readonly IMyRepository _myRepo;
public MyService(IMyRepository myRepo){ _myRepo = myRepo; }
Run Code Online (Sandbox Code Playgroud)
目前我需要在我的API的启动类中定义我的DI容器以使其工作.
我的问题是,如何在我的Core-project中将存储库的DI容器的"构建"放入我的服务中.这样,我的API与我的服务使用Entity Framework这一事实松散耦合,因此我可以更改为mongodb,而无需更改我的API项目.
dependency-injection separation-of-concerns autofac repository-pattern asp.net-core
我正在ASP.NET Core的新2.1版本中使用自签名证书,默认情况下如本文所述:https :
//docs.microsoft.com/zh-cn/aspnet/core/release-notes/ aspnetcore-2.1?view = aspnetcore-2.1
我已经使用命令信任它dotnet dev-certs https --trust
在Chrome和Edge中,我的API在调用时以绿色显示“连接安全”。但是,在Mozilla Firefox(Quantum 61.0.1)中,它给出了“连接不安全”,并显示以下错误:MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT
我该如何解决?如何配置Firefox以允许自签名证书?还是我必须在代码中做这件事?
是否可以将ASP.NET(核心)应用程序发布到IIS 8上的运行站点,而无需手动停止和启动网站?
Visual Studio 2015不断给出文件正在使用的错误.我正在使用发布到文件系统,因为我的网络部署到我们网络中的服务器最后失败了,它无法在端口443的服务器上进行身份验证.
我不介意IIS必须回收应用程序池,但是当我经常不得不放下应用程序,发布(大约需要一分钟)并重新启动它时,它对用户来说并不是很好.
另一种选择是类似于运行相同应用程序的2个网站,但前提是这是可自动化的.然后它会放下2中的1,更新它,把它打开,放下第二个,更新它并启动它.
第三个选项类似于热更新,我可以在应用程序启动时更新它.
任何人都可以指出我正确的方向(也许是一些博客文章),因为我的谷歌搜索没有给我任何好的信息?
我有一个ASP.NET 5(运行在4.6.2,而不是Core)应用程序.我想使用AutoMapper的ProjectTo <>()方法将数据库的结果投影到我的viewmodels.
我已经尝试了很多测试,但似乎在使用ProjectTo <>()时无法找到地图.在具有相同模型和viewmodel的不同位置上使用mapper.Map <>()非常有效.
我想AutoMapper如何与我的DI(Autofac)一起工作有问题,但我无法弄清楚是什么.
无论如何,代码:
Startup.Cs
public IServiceProvider ConfigureServices(IServiceCollection services)
{
(...)
// Autofac DI
AutofacContainer = AutofacLoader.Configure(services).Build();
return AutofacContainer.Resolve<IServiceProvider>();
}
Run Code Online (Sandbox Code Playgroud)
AutofacLoader.cs
public static ContainerBuilder Configure(IServiceCollection services)
{
var builder = new ContainerBuilder();
(...)
// AutoMapper
builder.RegisterModule<AutoMapperModule>();
if (services != null)
{
builder.Populate(services);
}
return builder;
}
Run Code Online (Sandbox Code Playgroud)
AutoMapperModule.cs
public class AutoMapperModule : Module
{
protected override void Load(ContainerBuilder builder)
{
var mapping = new MapperConfiguration(cfg =>
{
cfg.AddProfile(new Core.Mappings.AutoMapperProfileConfiguration());
cfg.AddProfile(new Dieet.Core.Mappings.AutoMapperProfileConfiguration());
});
builder.RegisterInstance(mapping.CreateMapper()).As<IMapper>().AutoActivate();
}
}
Run Code Online (Sandbox Code Playgroud)
测试因"从患者到患者视图缺失地图"而失败.使用Mapper.CreateMap创建'.
[Fact] …Run Code Online (Sandbox Code Playgroud) 我有一个 main.ts 文件:
import { App } from './app';
import './styles.scss';
ready(new App().init);
function ready(fn) {
if (document.readyState !== 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
Run Code Online (Sandbox Code Playgroud)
和一个 app.ts 文件:
export class App {
constructor() {
}
private print = (str: string) => console.log(str);
init(){
this.print('test');
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用 webpack 中的 ts-loader 使用此 tsconfig.json 运行此命令时:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"lib": ["es5", "dom", "es2015.iterable"]
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误: Uncaught TypeError: this.print is not a function at …
asp.net-core ×3
asp.net ×2
autofac ×2
c# ×2
asp.net5 ×1
automapper ×1
ecmascript-6 ×1
firefox ×1
https ×1
iis ×1
iis-8 ×1
javascript ×1
typescript ×1
updates ×1
webpack ×1