miércoles, 30 de octubre de 2019

Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".

Para solucionar esto en asp.net mvc,

Tuve que realizar la siguiente modificacion:


Este codigo originalmente estaba asi:

app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account. 
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });



Y luego, comente  lo de OnValidateIdentity quedando asi:



 app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account. 
                    //OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
                    //    validateInterval: TimeSpan.FromMinutes(30),
                    //    regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });

jueves, 15 de agosto de 2019

Obtener el dia de la semana SQL Server

El siguiente script devuelve el numero del dia de la semana

SELECT DATEPART(WEEKDAY, GETDATE())

Obtener el numero de semana del mes SQL server

Para obtener el numero de semana del mes en sql se puede usar el siguiente ejemplo:


DECLARE @DATE DATETIME
SET @DATE = '2019-06-01'

SELECT DATEPART(WEEK, @DATE)  -
    DATEPART(WEEK, DATEADD(MM, DATEDIFF(MM,0,@DATE), 0))+ 1 AS WEEK_OF_MONTH




Si se tiene en cuenta que el corte de semana  es luego del primer domingo:



declare @date datetime = '2019-06-03'
select datediff(week, dateadd(week, datediff(week, 0, dateadd(month, datediff(month, 0, @date), 0)), 0), @date - 1) + 1;

miércoles, 10 de abril de 2019

An error occurred while starting the application. .NET Core 4.6.27521.02 X64 v4.0.0.0 | Microsoft.AspNetCore.Hosting version 2.2.0-rtm-35687 | Microsoft Windows 10.0.17134

Para encontrar el posible error modifique el archivo de configuracion we.config

Cambiando el parametro stdoutLogEnabled=true

Y luego crea una carpeta logs en el directorio donde se encuntra la aplicacion. En el mismo se puede observar el problema que esta teniendo

HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid. Detailed Error Information: Module IIS Web Core

En el web.config hay que cambiar processPath  y reemplazar por donde esta fisicamente dotnet.exe




<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments=".\your-project.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout"/>
  </system.webServer>
</configuration>

martes, 26 de febrero de 2019

Configuracion formato fecha sql server

Para configurar el formato de la fecha en sql server se puede hacer  para el usuario de sesion:

ALTER LOGIN sa WITH DEFAULT_LANGUAGE=English


o por transaccion:

 SET DATEFORMAT ymd;



----
Para saber la configuracion actual se puede usar la siguiente consulta:


SELECT      type_desc,
    default_database_name,
    default_language_name
FROM master.sys.server_principals
WHERE name = 'sa';