I recently published my app into the IIS server in local to test my application under the next path: %SystemDrive%\inetpub\wwwroot\PDS
This is my app configuration under the 'Startup.cs' file:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddCors();
services.AddCors(options =>
{
options.AddPolicy("AllowAll",
builder => {
builder
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
/* Here I have my DB connections */
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
} else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCors("AllowAll");
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
app.UseSpa(spa => {
spa.Options.SourcePath = "ClientApp";
if(env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
spa.Options.StartupTimeout = TimeSpan.FromSeconds(2000);
}
});
}
}
My web.config file after publishing the application is this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\PDS.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
When I run the application by path given using IIS my app "Loads" but I get the next errors in console:
PDS/:9 GET http://MyServer/styles.71dabd29525fe744.css net::ERR_ABORTED 404 (Not Found)
PDS/:23 GET http://MyServer/main.d97cc394db065bba.js net::ERR_ABORTED 404 (Not Found)
PDS/:23 GET http://MyServer/runtime.04ca1c1b9692da3f.js net::ERR_ABORTED 404 (Not Found)
PDS/:25 GET http://MyServer/assets/Images/webb.png 404 (Not Found)
PDS/:23 GET http://MyServer/polyfills.059cb375bf3e0530.js net::ERR_ABORTED 404(Not Found)
aaaicon.ico:1 GET http://MyServer/assets/aaaicon.ico 404 (Not Found)
I have tried usign different methods like "UseSpaStaticFiles()" but didn't work either. My routes in my TS files are fine and my Logs doesn't show important information to see what's happening. What else could I try to get those files working properly?
Go to the path of your application and right click on that folder and then choose the Properties and go to the Security tab, from there, allow all the available options for the IIS user. And restart your application poll in IIS and lunch the app again