我首先使用EntityFramework Core数据库来创建模型,如EF Core文档中所示
但是我不知道在编辑数据库时如何更新模型.
我有以下内容逐行读取文件:
wscript.echo "BEGIN"
filePath = WScript.Arguments(0)
filePath = "C:\Temp\vblist.txt"
Set ObjFso = CreateObject("Scripting.FileSystemObject")
Set ObjFile = ObjFso.OpenTextFile(filePath)
StrData = ObjFile.ReadLine
wscript.echo "END OF FIRST PART"
Do Until StrData = EOF(ObjFile.ReadLine)
wscript.echo StrData
StrData = ObjFile.ReadLine
Loop
wscript.echo "END"
Run Code Online (Sandbox Code Playgroud)
该EOF()功能似乎不起作用:
C:\Users\EGr\Documents\Scripts\VB>cscript testloop.vbs ArgVal
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
BEGIN
END OF FIRST PART
C:\Users\EGr\Documents\Scripts\VB\testloop.vbs(11, 1) Microsoft VBScript runti
me error: Type mismatch: 'EOF'
Run Code Online (Sandbox Code Playgroud)
我以前没有在VB中编程,但是我想弄清楚循环,以便我可以修改我已经交过的VB脚本.我想逐行读取文件,并对每一行做一些事情.如果我将Do Until循环更改为Do Until StrData = EOF …
我今天通过以下命令行安装了 Blazor WebAssembly 示例项目 (WeatherForecast):
dotnet new blazorwasm --hosted -o ProjectName
Run Code Online (Sandbox Code Playgroud)
我在调试模式下通过 Visual Studio 2019 安装后直接启动了 SPA。浏览器是:Chrome。浏览器显示应用程序,但是当我选择导航菜单“获取数据”时,什么也没有发生。Chrome 显示 1 个错误:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: The provided ContentType is not supported; the supported types are 'application/json' and the structured syntax suffix 'application/+json'.
System.NotSupportedException: The provided ContentType is not supported; the supported types are 'application/json' and the structured syntax suffix 'application/+json'.
at System.Net.Http.Json.HttpContentJsonExtensions.ValidateContent (System.Net.Http.HttpContent content) <0x2e87f38 + 0x0009a> in <filename unknown>:0
at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync[T] (System.Net.Http.HttpContent content, System.Text.Json.JsonSerializerOptions options, System.Threading.CancellationToken cancellationToken) <0x2e87d30 + …Run Code Online (Sandbox Code Playgroud) asp.net asp.net-web-api blazor blazor-client-side blazor-webassembly
我正在尝试使用 Blazor 做一些事情,但我还是个新手。我正在尝试获取文件流以下载到浏览器。将文件从 Blazor 下载到浏览器的最佳方式是什么?
我试过在我的剃刀视图中使用一种方法来返回一个流,但没有用。
//In my Blazor view
@code{
private FileStream Download()
{
//get path + file name
var file = @"c:\path\to\my\file\test.txt";
var stream = new FileStream(test, FileMode.OpenOrCreate);
return stream;
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码没有给我任何东西,甚至没有错误
我们有一个使用 .NET Framework 4.6 的 ASP.NET 网站,我们使用 Rider 和 Visual Studio 来处理它。
每隔一段时间,我就会发现有人获取旧的 razor 文件,但仍然尝试查找不再存在的函数/引用。据我了解,这些 razor 文件已被缓存,我们需要清除缓存。
所以,我们通常会进行以下步骤
这些步骤的某些组合通常适用于大多数人,但当它不起作用时,我们必须手动转到每个 razor 文件(抱怨错误)并添加一个空格并保存它以强制清除缓存。有时是单个文件或 2 个文件,但有时是 10 个文件。
因此,想知道每当我们再次发现此问题时清除剃刀文件缓存的正确/推荐方法是什么。
我有一个简单的 Blazor 组件,它迭代通用列表:
@typeparam TItem;
@foreach (var item in List)
{
@ElementTemplate(item); // What code should be here to pass i to the ElementTemplate????
i++;
}
@code {
int i = 0;
[Parameter] public List<TItem> List { get; set; }
[Parameter] public RenderFragment<TItem> ElementTemplate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有另一个简单的组件,它将获取一个项目和一个索引来呈现数据(员工):
<div> @Index . @Person.Name </div>
@code{
[Parameter] public Person { get; set; }
[Parameter] public int Index { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在我的主页上有以下内容:
<GenericList List="employees">
<ElementTemplate>
<Employee Person="context" Index="?"></Employee>
</ElementTemplate> …Run Code Online (Sandbox Code Playgroud) 在 Blazor 中,某些东西(例如注入的对象和参数)必须使用属性,这部分很清楚。
但是那些用于控制页面内容和流程的特定于页面的变量(例如数据/DTO 和杂项字符串/布尔值等)又如何呢?
是使用自动属性(公共还是私有?)还是私有字段更好?
我问这个问题是因为在与 Blazor 相关的各种示例、教程和文档中,属性和字段的使用无处不在。我似乎找不到任何关于此的官方最佳实践指南。
在 .NET Core 2.2 中成功登录后,HttpContext.User.Claims 和 IHttpContextAccessor 均返回空值这里是我的启动服务,
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")
,b=>b.MigrationsAssembly("AdaptiveBizapp")));
services.AddDbContext<Project_Cost_Management_SystemContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("Project_Cost_Management_SystemContext")
, b => b.MigrationsAssembly("AdaptiveBizapp")));
services.AddDefaultIdentity<ApplicationUser>()
.AddRoles<ApplicationRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => false;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.ConfigureApplicationCookie(options => {
options.LoginPath = "/Account/login";
options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
});
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
// …Run Code Online (Sandbox Code Playgroud) claims-based-identity asp.net-identity .net-core asp.net-core
如何在我的web项目中使用mvc4使用两个不同的母版页或布局?
我有一个关于 asp.net core 和 razor 页面的非常简单的问题。
在 c# razor 代码中,我想在某些情况下重定向到另一条路线。如果之前有一个异步(等待)webservice 调用,NavigationManager.NavigateTo 不能正常工作,但也不会抛出异常。
async Task Cancel()
{
var authState = await authenticationStateTask;
var user = authState.User;
if (user.Identity.IsAuthenticated){
// if there's some async webservice call action here,
// NavigationManager.NavigateTo does neither work nor an exception is thrown
NavigationManager.NavigateTo("/Project", true);
}
}
Run Code Online (Sandbox Code Playgroud)
你知道可能是什么原因吗?
NavigationManager.NavigateTo的替代方法是什么?
PS请不要以那种方式提出Response.Redirect(因为,这不适合我)。
var context = new Microsoft.AspNetCore.Http.HttpContextAccessor();
context.HttpContext.Response.Redirect("/Project", true)
Run Code Online (Sandbox Code Playgroud)
亲切的问候,-他。