在创建新的ASP.NET Core MVC应用程序时使用的正确Docker镜像是什么,特别是使用React/Redux(或其他需要Node.js)模板?如果没有具体的形象,什么命令或程序应遵循在Dockerfile由ASP.NET MVC的核心支持的应用程序的Node.js?
除了运行支持MVC站点之外,我不需要框架的SDK版本.
dotnet new reactredux
运行时映像没有安装Node.js,并且在尝试运行容器时会出错.
Dockerfile:
FROM microsoft/aspnetcore:latest
ARG source=./bin/Debug/netcoreapp2.0/publish/
WORKDIR /app
COPY $source .
EXPOSE 80
ENTRYPOINT ["dotnet", "Project.dll"]
Run Code Online (Sandbox Code Playgroud)
错误:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Failed to start Node process. To resolve this:.
[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Make sure the Node executable is in one of those directories, or update your PATH.
Run Code Online (Sandbox Code Playgroud)
这个项目我与正在从ASP.NET MVC升级为.NET …
我希望有两个答案中的一个,要么不可能,要么非常简单,我忽略了明显的Google查询.
潜在的问题是我有一个通用对象通过一个EventHandler
框来传递对象并模糊真实类型; 只有在运行时我才知道对象是什么.
不可否认,dynamic
关键字可以解决这个问题,但我想不要失去智能感知,如果我可以避免它.另外,它没有解决不知道通用对象的每个属性没有大量反射的情况.
编辑:我们的想法是能够确定方法参数中对象的真实类型,然后在不事先知道的情况下将该对象转换为真实类型.这只是一个简化的例子.盒装可能是错误的术语.
一个例子:
public class Program
{
static void Main(string[] args)
{
var container = new Container<Containee>(
new Containee
{
Property1 = Guid.NewGuid(),
Property2 = "I'm a property!",
Property3 = DateTime.Now
}
);
var boxed = (object)container;
var originalType = boxed.GetType();
// DOES NOT COMPILE: would like an operation like this
// EDIT: Request for more detail
var actualType = boxed as originalType;
actualType.Entity.Property2 = "But I like this better.";
}
}
public …
Run Code Online (Sandbox Code Playgroud) 使用ASP.NET MVC(3或4DP)中的开箱即用方法定位器,有没有办法让MVC框架区分字符串和Guid而无需解析控制器操作中的参数?
用法示例适用于URL
执行
public ActionResult Details(Guid guid)
Run Code Online (Sandbox Code Playgroud)
方法,和
执行
public ActionResult Details(string id)
Run Code Online (Sandbox Code Playgroud)
方法.
没有任何变化,显然这些方法含糊不清,如下:
public ActionResult Details(Guid id)
{
var model = Context.GetData(id);
return View(model);
}
public ActionResult Details(string id)
{
var model = Context.GetData(id);
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
导致错误:
The current request for action 'Details' on controller type 'DataController' is ambiguous between the following action methods:
System.Web.Mvc.ActionResult Details(System.Guid) on type Example.Web.Controllers.DataController
System.Web.Mvc.ActionResult Details(System.String) on type Example.Web.Controllers.DataController
Run Code Online (Sandbox Code Playgroud)
我尝试使用自定义约束(基于如何创建System.Guid类型的路由约束?)尝试通过路由推送它:
routes.MapRoute(
"Guid", …
Run Code Online (Sandbox Code Playgroud) .net-core ×1
asp.net-core ×1
asp.net-mvc ×1
boxing ×1
c# ×1
docker ×1
generics ×1
guid ×1
node.js ×1
reflection ×1