0
votes

I am using .net Core and when I deployed my code I got the message "You do not have permission to view this directory or page." on my Azure´s App Service URL. Before the deployment I did not get this error.

My problem is that when I am trying to google this error I keep getting results that I have to make some adjustments in my web.config but .net Core does not have file. Deploying the program and using localhost works to make api calls works.

Anyone else here encounter the same problem using .net Core and figured out what the problem was???

Here is my Startup.cs file

public class Startup
{
    public IConfigurationRoot Configuration {get; set;}
    public static string ConnectionString {get; set;}        

    // public Startup(IConfiguration configuration)
    // {
    //     Configuration = configuration;
    // }

    public Startup(IHostingEnvironment env){
        Configuration = new ConfigurationBuilder()
                            .SetBasePath(env.ContentRootPath)
                            .AddJsonFile("appsettings.json")
                            .Build();
    }

    // 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);
    }

    // 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.UseHsts();
        }

        app.UseHttpsRedirection();
        app.UseMvc();

        ConnectionString = Configuration["ConnectionStrings:TestingConnection"];
    }
}
2
You have to share some code so we'd be able to help.Rafael Herscovici
Which file would you like to see? Startup.cs ???Stullz
that would be a good start.Rafael Herscovici
try adding these to your Configure method: app.UseDefaultFiles(); app.UseMvcWithDefaultRoute(); app.UseStaticFiles();Rafael Herscovici

2 Answers

0
votes

"You do not have permission to view this directory or page."

I assume that you have no default document. If it is that case, it is expected action.

You publish a Web Application project to azure, the default page will displayed correctly. In your case, if it is working in local, you could test azure Rest API directly.

The default document is the web page that is displayed at the root URL for a website. The first matching file in the list is used. Web apps might use modules that route based on URL, rather than serving static content, in which case there is no default document as such.

0
votes

We discovered that publishing to azure using the command line was no problem at all so our API service is now up and running.

Just for some reason we were not able to do it with the Azure add on we installed in visual studio code