我在 ASP.NET Core 3 预览版 4 中使用服务器端 Blazor 组件。
我有一个父组件和子组件,使用相同的共享模型,如下所示:
模型 :
public class CountModel
{
public int Count { get; set; }
public void Increment()
{
Count++;
}
}
Run Code Online (Sandbox Code Playgroud)
父组件:
@page "/count"
<CascadingValue Value="currentCount">
<h1>Count parent</h1>
<p>Current count is : @currentCount.Count</p>
<button class="btn btn-primary" onclick="@currentCount.Increment">+1 from parent</button>
<CountChild></CountChild>
</CascadingValue>
@functions {
private CountModel currentCount = new CountModel();
}
Run Code Online (Sandbox Code Playgroud)
子组件:
<h1>Count child</h1>
<p>Current count is : @currentCount.Count</p>
<button class="btn btn-primary" onclick="@currentCount.Increment">+1 from child</button>
@functions {
[CascadingParameter]
private CountModel currentCount { …Run Code Online (Sandbox Code Playgroud) 我为我的 ASP.NET Web 应用程序创建了一个自定义配置提供程序,我从其中继承Microsoft.Extensions.Configuration.ConfigurationProvider,并Load()覆盖该方法并IDictionary<string, string> Data使用新的Dictionary<string, string>().
所以我有一个 appsettings.json 配置文件,包含
{
"Token" : "Token 1"
}
Run Code Online (Sandbox Code Playgroud)
在我的自定义提供程序中,我用“Token 2”覆盖 Token
我的代码中有一个错误,我在其中调用了configuration["token"](小写),并且我注意到应用程序设置中的值已加载,但不是我的自定义提供程序中的值。
因此,appsettings 配置似乎不区分大小写,但我的自定义提供程序则不然。
那么应该是这样吗?我刚刚创建了一个新字典,我不确定是否可以在不编写更多代码的情况下使其不区分大小写。
我正在尝试在我的 angular 应用程序中播放视频,它似乎适用于除 Safari 之外的所有浏览器:
<video controls autoplay muted class="media">
<source src="https://my-site/files/video.mp4" type="video/mp4" />
</video>
Run Code Online (Sandbox Code Playgroud)
我见过这样的问题:HTML5 Video tag not working in Safari , iPhone and iPad,它没有解决我的问题。
起初,我遇到了字节范围的问题,我修复了它,但它仍然不起作用。
如果我将视频标签放在一个空的 html 网页中,视频会播放,但在我的 angular 应用程序中它仍然没有。
我使用 fiddler 来获取 http 跟踪,并且有我不明白的差异。
当我在空网页中有标签时,我有以下请求:
GET https://my-site/files/video.mp4 HTTP/1.1
Host: (my-site)
Accept-Encoding: identity
X-Playback-Session-Id: 14692D0E-A88B-4253-8B8A-BC580AB82174
Accept-Language: fr-fr
Range: bytes=0-1
Accept: */*
User-Agent: Mozilla/5.0 (iPod touch; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1
Referer: (http://my-site/)
DNT: 1
Connection: keep-alive …Run Code Online (Sandbox Code Playgroud) 我正在使用asp.net core,在调用完整的Web应用程序之前,我想从请求中获取一些数据。
因此,我创建了一个中间件来执行此操作。我找到了一种检查所需内容的方法,但是我不知道如何将变量传递给以下中间件
app.Use(async (context, next) => {
var requestInfo = GetRequestInfo(context.Request);
if(requestInfo == null)
{
context.Response.StatusCode = 404;
return;
}
// How do I make the request info available to the following middlewares ?
await next();
});
app.Run(async (context) =>
{
// var requestInfo = ???
await context.Response.WriteAsync("Hello World! - " + env.EnvironmentName);
});
Run Code Online (Sandbox Code Playgroud)
是否存在将数据从中间件传递给其他人的好方法?(我在这里使用app.Run,但我希望在MVC中拥有所有这些功能)
我正在尝试以最少的配置来配置项目。我想使用VueJS和Typescript。
我将vue.js文件和脚本添加到我的主页:
<script src="~/lib/vue/dist/vue.js"></script>
<script src="~/js/site.js" ></script>
Run Code Online (Sandbox Code Playgroud)
一切正常。
但是,如果我想使用Typescript,则找不到Vue 类:
Symbol 'Vue' cannot be properly resolved, probably it is located in inaccessible module
Run Code Online (Sandbox Code Playgroud)
由于定义文件使用导出,因此必须将Vue用作模块。
如果添加导入,它将进行编译,但将在输出中使用,并且将无法在浏览器中运行。
有没有一种方法可以在不使用webpack的情况下进行这项工作?
我想使用 a<select>能够在多个值之间进行选择,或者不选择。
我的组件是这个:
<select @bind="SelectedValue">
<option value="null">Null</option>
@for (int i = 0; i < 10; i++)
{
<option value="@i">Value : @i </option>
}
</select>
<hr />
@if (SelectedValue.HasValue)
{
<p>The selected value is : @SelectedValue.Value</p>
}
else
{
<p>the value is null</p>
}
@code {
private int? SelectedValue = null;
}
Run Code Online (Sandbox Code Playgroud)
我可以将<select>值绑定到一个int对象,但我无法绑定该null值。是否有我应该使用的特殊语法,或者只是不支持?
在页面之间导航时,我的WinJS应用程序中随机崩溃.
问题是当应用程序附加到Visual Studio调试器时,这些崩溃永远不会发生; 所以我找不到他们来自哪里.
我使用WinJS.Application.onerror事件来防止崩溃,并记录发生的事情,但是当我尝试使用随机异常时这很好用,我的"无法捕获"崩溃似乎没有触发此事件(我没有任何记录).
您是否知道可能导致这些崩溃的原因,或任何解决方案以找到更多信息?
asp.net-core ×4
blazor ×2
c# ×2
angular ×1
html5-video ×1
ios ×1
safari ×1
typescript ×1
vue.js ×1
windows-8 ×1
winjs ×1