- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
在我的 asp.NET core React 应用程序中,startup.cs 文件中有一个位置定义了 React 源目录的路径。
app.UseSpa(spa =>
{
var path = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp");
spa.Options.SourcePath = path;
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
<小时/>
整个 Startup.cs
和 Program.cs
文件如下所示
Program.cs
public static void Main(string[] args) {
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup < Startup > ();
Startup.cs
public Startup(IConfiguration configuration) {
Configuration = configuration;
}
public IConfiguration Configuration {
get;
}
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) {
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration => {
configuration.RootPath = "ClientApp/build";
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseExceptionHandler("/Error");
app.UseHsts();
}
//app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSpaStaticFiles();
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
app.UseSpa(spa =>
{
var path = Path.Combine(Directory.GetCurrentDirectory(), "ClientApp");
spa.Options.SourcePath = path;
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
}
<小时/>
VS 2017 解决方案
使用默认的IIS Express
配置开始调试
VS 代码文件夹
使用launch.json
中默认的.NET Core Launch (web)
配置开始调试
但在这种情况下,Directory.GetCurrentDirectory()
会为 VS 2017 和 VSCode 返回不同的路径。 (这可能是由于上下文而预期的)。SPA 源文件夹 ClientApp
与 Startup.cs
、其他必要文件和 Controllers
文件夹一起驻留在 SolutionFolder/Presentation/
中。 Presentation
设置为 StartUp 项目。
如何相对地定义该路径,使其不会根据 IDE、环境或构建而改变?
最佳答案
解决了我猜的问题。在 VS2017 中设置为启动项目也会将当前工作目录设置为该路径。这会反射(reflect)在 CurrentRoothPath
或 Directory.GetCurrentDirectory()
的值中。
但是在使用默认调试配置的 VSCode 中,当前目录指向打开的文件夹的根目录(而不是任何项目或子文件夹)。
我必须将 launch.json
中 cwd
的值从 "${workspaceFolder}"
更改为 "${ workspaceFolder}/ReportingTool.Presentation"
根据文档:
cwd - current working directory for finding dependencies and other files
所以我不完全确定这将如何影响生产构建或其他依赖项。这暂时解决了这个问题。希望有人能进一步澄清。
关于c# - Startup.cs 中 SPA 源路径的 GetCurrentDirectory() 为 VS2017 和 VS Code 返回不同的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54171010/
我正在看的是在另一个 React 微前端中有一个有角度的微前端,这是我们可以通过 single-spa 实现的吗 最佳答案 是的,这可以通过两种方式完成。这取决于您的应用程序使用的框架。 选项 1:跨
总结:如何在不使用繁重的 JS 框架的情况下处理 PWA 中的导航、历史记录和深度链接? 在领导团队将现有的购物网站从 Angular 1 SPA 转换为多页面应用程序 (MPA) PWA 时,我遇到
我正在尝试使用 Angular.js 和 Express.js 创建 Node.js 应用程序。 我正在做的是使用此代码将客户名称和地址添加到列表(随机)。 var mylist = new gene
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 8 年前。 Improv
所以我在 Laravel 5.3 和 Vue 2 中开发一个网站/网络应用程序。SEO 很重要,所以我想在 Laravel + Blade 中保留网站的前端/可抓取部分,并且只保留一些不必要的小部分在
我设置了一个单页应用程序,它使用 Controller (用 PHP 编写)从 API 获取数据。到目前为止,我没有遇到任何问题,数据填充表,在选择表元素时它会使用新的 url 和部分数据(主要是 I
因此,我一直在尝试找出有关如何在 SPA 应用中处理授权(而不是身份验证)的最佳实践。 假设我有一个带有 api 后端的客户端 MVC(Angular、vuejs 等),我们如何管理应用程序的使用授权
SPA 的缺点当然是初始加载时间。 例如,我用 Durandal 创建了 AskACarPro.com。 它目前在加载时有一个“加载”屏幕。但我在想也许这是一个坏主意。它让我想起了一个全闪存网站——漂
我最近一直在阅读有关 SPA 以及它有多好的内容。 我想知道是否有人可以告诉我什么时候应该使用,或者什么时候不应该像常规 MVC 一样使用 SPA 最佳答案 MVC(Rails、MVC4)的工具更加成
基本设置:由Apache 2.4提供的Angular 1.5 SPA由REST api支持,Apache 2.4也提供了REST API。 我已经阅读了在服务器上更改了一些应用程序代码后可以使SPA更
在典型的单页应用程序(SPA,例如:React)中,整个代码包都提供给客户端。这包括应用程序的私有(private)组件,这些组件通常受到客户端授权机制的保护(例如,检查身份验证 token 是否已设
我想单独托管我的 应用程序和 网站 .层次结构如下: example.com - 网站托管在 DigitalOcean example.com/* - SPA 托管在 Firebase Hosting
我正在寻找可重复使用的解决方案,以解决用户执行的某些操作在完成之前可能需要用户进一步确认的问题。 我正在使用 React 前端和 WebAPI 后端开发应用程序。 假设用户正在发起资金转账,并假设我们
我有一个像这样的网站 http://domain/?key=32dxzQW 其中 key 是从每个用户的其他站点自动生成的 我需要知道的是访问量最大的部分,所以我正在考虑使用 GA,并且由于我的网页是
我真的很喜欢GunDb的概念,并且了解如何单独在客户端编写。 现在我使用来自 Github 的 Create-React-App。 有人知道 GunDb 的服务器端吗? 和一个 View [React
假设 ABC 公司有两个团队开发两个 SPA 应用程序:app1、app2 每个应用程序都有自己的 index.html 和关联的静态资源,例如: build / 索引.html 主.js 这是从:h
我一直在使用 AngularJS 开发 SPA,并将用户数据存储在 Angular Value 服务中,但我对此感到不舒服,主要是因为 Angular Value 不在浏览器选项卡之间共享。因此,如果
假设 ABC 公司有两个团队开发两个 SPA 应用程序:app1、app2 每个应用程序都有自己的 index.html 和关联的静态资源,例如: build / 索引.html 主.js 这是从:h
因此,我使用 Gorilla/Mux 在 Go 中设置了我的 SPA,但我想在不同的路由上运行它,这样我就可以将我的两个 Kubernetes 服务连接在一起(2 个不同的 SPA)。 难道我必须将我
我正在创建一个单页应用程序。我试图在 sql 中选择一个表并在字段中搜索特定日期 Date_Due,然后确保另一个字段 Date_Complete 为空。我试图弄清楚如何让隐藏字段填充查询中的 cfp
我是一名优秀的程序员,十分优秀!