我正在尝试使用 Angular 模板创建 ASP.NET Core 6,我使用的是 VS 2022 和 .net 6,npm 是最新版本,Node js 也是如此。
我遵循了正常的项目步骤: 1- 创建一个项目。2- ASP.NET Core 与角度。3-然后在最新的一步中我选择了Framework作为.NET 0.0(长期支持)
认证类型为个人账户。
4-然后我编辑连接字符串以匹配我的数据库连接字符串。
但问题是,当我开始运行该项目时,它会打开一个新的浏览器,如下面的屏幕截图所示,带有两个命令:
我在 cmd 中看到以下错误:
Couldn't start the SPA development server with the command 'npm start'.
Run Code Online (Sandbox Code Playgroud)
请注意,我尝试了以下链接中建议的解决方案,但没有成功:
我正在尝试在某个组件中设置变量值(从 angular 选择组件中选择的选项)以在另一个组件中使用它,我不想通过 javascript 使用 window.sessionStorage()我想在.NET core 但问题是我可以设置变量值,但是当我想获取它时,它没有返回值。
以下是我的应用程序服务代码
public class MainProjectAppService : AsyncCrudAppService<MainProject, MainProjectDto,int,PagedAndSortedResultRequestDto,MainProjectDto>
{
private readonly IHttpContextAccessor _httpContextAccessor;
public MainProjectAppService(IRepository<MainProject, int> repository, IHttpContextAccessor httpContextAccessor) : base(repository)
{
_httpContextAccessor = httpContextAccessor;
}
public void setVaraibleValurinSesseion(int ID)
{
_httpContextAccessor.HttpContext.Session.SetInt32("GID", ID);
}
public int getVaraibleValurFromSesseion()
{
return (int)_httpContextAccessor.HttpContext.Session.GetInt32("GID");
}
Run Code Online (Sandbox Code Playgroud)
using System;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Castle.Facilities.Logging;
using Abp.AspNetCore;
using Abp.AspNetCore.Mvc.Antiforgery;
using Abp.Castle.Logging.Log4Net;
using Abp.Extensions;
using …Run Code Online (Sandbox Code Playgroud) session-variables asp.net-boilerplate asp.net-core aspnetboilerplate angular
我正在使用带有角度的 ASP.net 核心样板。我尝试在 IIS localhost 下分别托管两个应用程序的 Angular 网站和 .NET 核心网站,没有问题。
:
但是当我想在公共上部署我的应用程序时,我遇到了这个问题:
1- 我只有一个公共 IP 重定向到 IIS 默认网站,并且每个应用程序都有一个不同的端口。
**因此,前端和后端都应托管在具有不同端口的 IIS 默认网站下。
更新
这是我的 appsetting.json
{
"ConnectionStrings": {
"Default": "Server=localhost\\SQLEXPRESS; Database=MyDb;User Id=admin;Password=1234"
},
"App": {
"ServerRootAddress": "http://localhost:21021/",
"ClientRootAddress": "http://localhost:4200/",
"CorsOrigins": "http://localhost:4200,http://localhost:8080,http://localhost:8081,http://localhost:3000"
},
"Authentication": {
"JwtBearer": {
"IsEnabled": "true",
"SecurityKey": "MyApp_C421AAEE0D114E9C",
"Issuer": "MyApp",
"Audience": "MyApp"
}
}
}
Run Code Online (Sandbox Code Playgroud)
更新 2
角度 web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension="woff" …Run Code Online (Sandbox Code Playgroud) 我计划构建 Web 应用程序并使用 SignalR 库来允许 Web 管理员与其他用户聊天(使用移动应用程序)
1-系统管理员使用由 Asp.net Boilerplate (.NET Core 3.1) 构建的 Web 应用程序。
2- 其他用户使用由(QT Mobile 应用程序)构建的移动应用程序
那么,这个场景是否适用于 SignalR 库,或者我会遇到一些限制,尤其是 QT Mobile 应用程序?
更新:
为什么我想要这种方法?
因为我使用的是 Esri QML SDK(在移动应用程序中)
我正在尝试将最新的 Angular Material 与 Angular 9 一起使用,但我遇到了以下问题
这是我的 app.modul.ts
import { NgModule } from '@angular/core';
import { CommonModule, CurrencyPipe } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientJsonpModule } from '@angular/common/http';
import { HttpClientModule } from '@angular/common/http';
import { ModalModule } from 'ngx-bootstrap/modal';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { NgxPaginationModule } from 'ngx-pagination';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent …Run Code Online (Sandbox Code Playgroud)