Foros del Web » Programación para mayores de 30 ;) » .NET »

permisos de escritura en archivo txt

Estas en el tema de permisos de escritura en archivo txt en el foro de .NET en Foros del Web. He tenido que formatear el disco e instalar otra vez todo y ahora cuando lazo la aplicacion me dice lo siguiente, que antes no me ...
  #1 (permalink)  
Antiguo 14/06/2005, 09:14
 
Fecha de Ingreso: marzo-2004
Mensajes: 198
Antigüedad: 20 años, 11 meses
Puntos: 1
permisos de escritura en archivo txt

He tenido que formatear el disco e instalar otra vez todo y ahora cuando lazo la aplicacion me dice lo siguiente, que antes no me decia,

Access to the path "F:\Inetpub\wwwroot\inicio\contador.txt" is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path "F:\Inetpub\wwwroot\inicio\contador.txt" is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:


Line 74: Label2.Text = "Visitas: " + CType(num, String)
Line 75: objStreamReader.Close()
Line 76: objStreamWriter = File.CreateText(MapPath("contador.txt"))
Line 77: objStreamWriter.WriteLine(CType(num, String))
Line 78: objStreamWriter.Close()

Alguien sabe que tengo que hacer para que la aplicacion entre de manera impersonating.

Gracias anticipadas
  #2 (permalink)  
Antiguo 14/06/2005, 18:27
Avatar de xknown  
Fecha de Ingreso: diciembre-2004
Ubicación: Cusco - Perú
Mensajes: 2.248
Antigüedad: 20 años, 1 mes
Puntos: 7
Si quieres que la aplicación se ejecute bajo un usuario diferente puedes poner esto dentro del web.config:

<identity impersonate="true" userName="usuario" password="contraseña"/>

Saludos
__________________
Alex Concha
Buayacorp - Programación y Diseño
  #3 (permalink)  
Antiguo 15/06/2005, 09:38
 
Fecha de Ingreso: marzo-2004
Mensajes: 198
Antigüedad: 20 años, 11 meses
Puntos: 1
no va

Lo he metido dentro del webconfig y me da error. Hay que ponerlo en algun apartado especifico del web config

saludos
  #4 (permalink)  
Antiguo 15/06/2005, 16:27
 
Fecha de Ingreso: marzo-2004
Mensajes: 198
Antigüedad: 20 años, 11 meses
Puntos: 1
ya va

he puesto solo
<identity impersonate="true" />
y funciona pero ahora me gustaria saber que estoy haciendo. Esto conlleva algun riesgo en seguridad

Gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:15.