En este pedazo creo el boton para la descarga
<%If (PortalSecurity.IsInRole("Administrators Users")) Or (PortalSecurity.IsInRole("Registered Users")) or (PortalSecurity.IsInRole("Unauthenticated Users")) Then%>
<td class="style1">
<asp:Button ID="btnDesc610" runat="server" ForeColor="Blue" Text="Descargar" />
</td>
<%End If%>
En este pedazo de codigo esta el metodo que ejecuta la accion de descargar.
Protected Sub btnDesc6101_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDesc610.Click
If (PortalSecurity.IsInRole("Unauthenticated Users")) Or (PortalSecurity.IsInRole("Administrators")) Or (PortalSecurity.IsInRole("Registered Users")) Then
'MsgBox("ENTRO")
Dim fs As IO.FileStream = Nothing
Dim path As String = "C:\inetpub\wwwroot\corpocesar\documentos\NormatividadReal\res_0610_240310.pdf"
'obtenemos el archivo del servidor
fs = IO.File.Open(path, IO.FileMode.Open, IO.FileAccess.Read)
Dim byteBuffer(CInt(fs.Length - 1)) As Byte
fs.Read(byteBuffer, 0, CInt(fs.Length))
fs.Close()
Using ms As New IO.MemoryStream(byteBuffer)
'descargar con su nombre original
Response.AddHeader("Content-Disposition", "attachment; filename=resolucion_610_2010.pdf")
ms.WriteTo(Response.OutputStream)
End Using
End If
End Sub
como pueden ver hago las coprobaciones correspondientes de los usuarios pero ni siquierea con eso. He puesto la comprobacion directamente en la creacion del boton, en el code behind y en ninguno de los dos.
Muchas gracias por la colaboracion prestada.