Problems publishing an Asp.net application on IIS

Asked

Viewed 1,103 times

0

I am trying to publish my application on a Windows server 2012 with IIS 8. I have taken the step by step to go to "Site -> Add Website" and fill in the coordinates, paths and etc. I have deployed it in the default folder "Inetpub -> wwwroot"however, I get the following errors when testing on the server itself or accessing the url from outside on my intranet.

inserir a descrição da imagem aqui

By Chrome

inserir a descrição da imagem aqui

Both above I am using by IIS a 'Authentication = Disabled'. When I step to 'Authentication = Enabled' this is the error:

inserir a descrição da imagem aqui

My webconfig is like this:

<?xml version="1.0" encoding="utf-8"?>

<customErrors mode="Off"/>
<roleManager enabled="true" defaultProvider="CustomRoleProvider">
  <providers>
    <clear />
    <add name="CustomRoleProvider" type="Competências.Business.CustomRoleProvider" connectionStringName="DefaultConnection" applicationName="/"/>
  </providers>
</roleManager>

<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />


<globalization uiCulture="pt-BR" culture="pt-BR" enableClientBasedCulture="true" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />
<authorization>
  <deny users="?" />
</authorization>

<pages>
  <namespaces>
    <add namespace="System.Web.Helpers" />
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Optimization" />
    <add namespace="System.Web.Routing" />
    <add namespace="System.Web.WebPages" />
  </namespaces>
</pages>

And my connectionstring:

public const string CONNECTION_STRING = @"Data Source=XXXXXX;Initial Catalog=Competências;User Id=integracao;Password=XXXXX;MultipleActiveResultSets=True;";
 public const string DEVELOPMENT_CONNECTION_STRING = @"Data Source=XXXXXX;Initial Catalog=Competências;Integrated Security=SSPI;MultipleActiveResultSets=True;";

What is missing to configure correctly to be able to publish my application?

1 answer

1

The problem accused by the error page is that the user is blank. See the message:

Login failed for user ''

Single quotes at the end of the message, indicates the name of the user being sent.

In your connection string DEVELOPMENT_CONNECTION_STRING, you use security integrated with windows. When you modified the authentication to enabled=true, most likely you allowed anonymous authentication on IIS.

To fix, add the following configuration to the web.config:

<system.web>
   <authentication mode="Windows" />
</system.web>

This setting will make IIS identify the user who is accessing your site and pass this user to authentication in the database.

Precautions: You should study how to best authenticate the users who will access this site. If it is an intranet site, maybe this type of authentication is the best way, otherwise I advise you to look for some authentication standards for ASP.NET.

More information on how to modify the IIS authentication mode, see this article on MSDN

  • added the suggested code @Anmaia to webconfig. Now the error is Login failed for user 'Dominio servidordoIIS$'.

  • What you should do and configure your application pool to use the Windows user as well. Most likely you are using Localsystem, you should change the identity to Applicationpoolidentity, see if that link help you.

  • I had already checked this... Was Applicationpoolidentity already.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.