嗨,我想从Ninject切换到AutoFac,但我遇到了一些问题.错误是:
Controllers.API.Basic.AddressController'没有默认构造函数
我在启动时注册了这个:
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
builder.RegisterType<AddressRepository>().As<IBaseRepository<Address>>();
builder.RegisterAssemblyModules(Assembly.GetExecutingAssembly());
IContainer container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
Run Code Online (Sandbox Code Playgroud)
这是我的控制器:
public class AddressController : GenericBaseController<Address>
{
public AddressController(IBaseRepository<Address> repository)
: base(repository)
{
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?这适用于Ninject.
Following situation:
I have a third party tool which executes the nunit-console.exe to run unit tests. I've switched the tests to dot net 5.0 as this is a new requirement in our company. Now when I run the nunit-console.exe (Version: NUnit Console Runner 3.12.0-beta2) in the console the same way the third party app does I get this error:
>E:\Nunit\netcoreapp3.1\nunit3-console.exe "C:\Tests\bin\Debug\net5.0\Tests.dll"
it was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- …Run Code Online (Sandbox Code Playgroud) 我想知道是否有可能以某种方式将一个亲戚filepath作为字符串发送到GET方法.
我的方法:
public HttpResponseMessage Get([FromUri] string fileName)
My route:
config.Routes.MapHttpRoute(
name: "MiscApiDownload",
routeTemplate: "api/{controller}/download/{fileName}",
defaults: new {action = "Download" }
);
Run Code Online (Sandbox Code Playgroud)
文件名就像"test.jpg"工作,但只要我有一个subdirexp."folder/test.jpg"该方法不再被发现.这是合乎逻辑的.问题是如果有一个很好的方法在URI中执行此操作.我不想在体内接受它.