Change root in angular with asp.net core application

Change root in angular with asp.net core application



I want to change root in my application from angular-cli.json or startup.cs, when I debug the home page always is index.html in folder " wwwroot ".
I'am using .net core 1.1.


angular-cli.json


startup.cs


index.html





This is my code in angular-cli.json:


angular-cli.json


"apps": [

"root": "src",
"outDir": "wwwroot",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": ,
"environmentSource": "environments/environment.ts",
"environments":
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"




What would be the problem?




1 Answer
1



Try and use the following:



startup.cs:


startup.cs


public void ConfigureServices(IServiceCollection services)

services.AddMvc();

// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =>

configuration.RootPath = "your/folder/path";
);



description:



Gets or sets the path, relative to the application root, of the
directory in which the physical files are located.



If the specified directory does not exist, then the
Microsoft.Extensions.DependencyInjection.SpaStaticFilesExtensions.UseSpaStaticFiles(Microsoft.AspNetCore.Builder.IApplicationBuilder)
middleware will not serve any static files






I did that but there is an exception " iservicecollection does not contain a definition for addspastaticfiles ",so i have installed " Install-Package Microsoft.AspNetCore.SpaServices -Version 1.1.1 " and put using ... in the top of startup.cs file , also i have .csproj file two packages ( <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="1.1.1" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" /> ) but the same exception appear !!

– mecab95
Sep 13 '18 at 15:26




Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế