Code: Detail

asp.net+core2 - (Portuguese)

Pasta diferente de wwwroot p/ arquivos estaticos

Script que permite utilizar uma outra pasta diferente de wwwroot para apontamento de arquivos estaticos em suas views

Last update: 05/09/2018
asp.net+core2       
 
N/A
N/A
N/A
N/A
 

public void Configure(IApplicationBuilder app)
{
    //Diz ao asp.net para utilizar o Diretorio padrão
    app.UseStaticFiles(); 

    //Diz ao asp.net que iremos utilizar no mesmo nivel do wwwroot uma outra pasta
    //contendo arquivos estaticos a pasta MeusScripts
    app.UseStaticFiles(new StaticFileOptions
    {
        FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "MeusScripts")),
        RequestPath = "/MeusScripts"
    });
}

/*
Exemplo de utilização
*/

<img src="~/MeusScripts/images/minhaimagem.jpg"  />

Source: https://docs.microsoft.com/pt-br/aspnet/core/fundamentals/index?view=aspnetcore-2.1#web-root
 
Users who have marked this routine as a favorite
 
 
 
The site ti4fun is not responsible for the content on sites for which you have external links

Articles, routines, tips, forums, blogs or any other content posted on ti4fun site is not tested and not validated, so you should test and validate any information collected on the ti4fun site before applying it to final use environment, such as example, production. the TI4FUN site is not responsible for quality or for any damages, direct, indirect or consequential, from use of any content posted by the authors in the site.

All content published on the ti4fun site is the responsibility of the author and do not necessarily express the views of the site ti4fun and its employees.