我想将解决方案至少分为两部分:
因为我希望在配置过程的后期阶段可以替换托管配置。
我尝试将所有包含控制器,模型和视图的文件夹简单地移动到一个单独的项目中,如下图所示:
托管配置和业务逻辑分离的两个项目:
所以我
using Microsoft.AspNetCore.Mvc;
namespace MyApp.Implementation.Controllers
{
public class ExampleController : Controller
{
public ActionResult<int> Index()
{
return 5;
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果启动应用程序并在浏览器中打开http:// localhost:5000 / example,则在浏览器中得到的结果为“ 5”。这向我表明,托管技术可以在单独的项目中找到我的控制器。
但是,当我在浏览器中打开http:// localhost:5000时,我得到一个异常页面,告诉我找不到Home-Controller的视图。控制台还显示异常:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
/Pages/Shared/Index.cshtml
Run Code Online (Sandbox Code Playgroud)
由于虚拟主机找到了我的控制器,所以我希望它也能找到视图。似乎并非如此。
我怎样才能告诉Web主机在哪里寻找视图呢?还是我需要对他们做任何事情?
我有这个 Xamarin 表单页面:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TestApp1"
x:Class="TestApp1.MainPage">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<WebView Source="http://www.google.de" HeightRequest="3000" WidthRequest="100"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
当我打开应用程序时,在谷歌提示中输入任何内容,我无法在结果页面上滚动。我如何启用此功能?
当我搜索“xamarin webview启用滚动”时,我只找到有关禁用它的信息......
我的网页上有一个使用 Chart.js 的条形图。
我已经使用添加了两个数据点
chart.addData([5], "A");
chart.addData([7], "B");
Run Code Online (Sandbox Code Playgroud)
现在我想更新这些条 A 和 B,而不删除它们并再次添加它们(我已经知道如何做到这一点)。我希望它们垂直移动以适应新值,但我不知道如何访问图表中已有的数据。
没有什么比
chart.updateData(0,[6]);
chart.updateData(1,[9]);
Run Code Online (Sandbox Code Playgroud)
其中第一个值是存储数据的索引 (fe)。
我该怎么做?
我有一个cmdlet,我接受一个字符串列表作为参数,在ac#类中定义如下:
[Parameter(Mandatory = true)]
public List<string> AllowedScopes;
Run Code Online (Sandbox Code Playgroud)
因此,当我调用我的命令时Add-Client,如何在PowerPhell中提供字符串列表?我试过这个(每一行都是一种不同的方法):
-AllowedScopes scope1, scope2, scope3
-AllowedScopes [scope1, scope2, scope3]
-AllowedScopes {scope1, scope2, scope3}
-AllowedScopes {"scope1", "scope2", "scope3"}
Run Code Online (Sandbox Code Playgroud)
但我总是只在我的列表"AllowedScopes"中获得一个条目,其中包含在AllowedScopes参数名称后输入的完整字符串.
我不能轻易找到任何关于此的内容,所以我想我问的是错误的问题.
我当然可以将AllowedScopes参数设置为一个简单的字符串,然后执行以下操作:
var AllowedScopesAsList = this.AllowedScopes.Split(',').ToList();
Run Code Online (Sandbox Code Playgroud)
但我认为这应该是由PowerShell提供的东西(因为它提供了许多其他有用的功能,使我无法实现我的cmdlet的整个用户交互部分)
编辑:这是我的cmdlet C#-class的全部内容:
using System.Collections.Generic;
using System.Management.Automation;
namespace MyCmdlets
{
[Cmdlet("Add", "Client")]
public class AddClient : Cmdlet
{
[Parameter(Mandatory = true)]
public List<string> AllowedScopes;
protected override void ProcessRecord()
{
AllowedScopes.ForEach(a => WriteObject(a));
}
}
}
Run Code Online (Sandbox Code Playgroud)
有了这个,如果我尝试进入列表就像其中一个答案说:
Add-Client -AllowedScopes @('scope1', 'scope2')
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
<pre>
scope1
scope2
</pre>
Run Code Online (Sandbox Code Playgroud)
这是预期的. …
我刚刚发现,当输入负x和小数y时,Math.Pow()返回未定义的值作为结果,这是错误的我猜.在其他程序中计算,即使像Windows计算器也可以使用正确的结果.此案例也未在文档中提及.
目标框架是4.
有谁能解释一下?
c# ×2
asp.net-core ×1
chart.js ×1
javascript ×1
math ×1
parameters ×1
pow ×1
powershell ×1
webview ×1
xamarin ×1