-1

I'm trying to use Material Design Icons in my project. I'm able to make a page successfully, but when I add icons to the page using i tags as described in materializecss documentation their class have the default path i.e. in font/material-design-icons/allFOntsfileshere. The problem is that when I add these my browser keeps saying "restricted access".

<div class="row margin">
    <div class="input-field col s12">
        <i class="mdi-social-person-outline prefix"></i>
        <input id="MobileNumber" type="text">
        <label for="MobileNumber" class="center-align indigo-text darken-2">
            Mobile Number
        </label>
    </div>
</div>
ekad
  • 14,436
  • 26
  • 44
  • 46

1 Answers1

-1

You could give a bit more context (eg. how are you configuring your middleware). But since I stumbled upon a similar problem I think I might guess what's he issue you're having.

You probably haven't configured static files middleware. You should check Microsoft's documentation article on Working with static files in ASP.NET Core, but here's what you should do to fix it in case the url changes:

First you need to set your ContentRoot in your Program.cs

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory()) //Like this
        .UseIISIntegration()
        .UseStartup<Startup>()
        .Build();

    host.Run();
}

In order for static files to be served, you must configure the Middleware to add static files to the pipeline. The static file middleware can be configured by adding a dependency on the Microsoft.AspNetCore.StaticFiles package to your project and then calling the UseStaticFiles extension method from Startup.Configure:

public void Configure(IApplicationBuilder app)
{
    /*...*/
    app.UseStaticFiles();
    /*...*/
}

You need to consider that the order in which you add your middleware matters. See this answer that specifies the required order between UseStaticFiles and UseDefaultFiles.

Community
  • 1
  • 1
Maximo Dominguez
  • 2,075
  • 18
  • 35