Mensaje dentro de Foro C#

Responder 
#1 - 14/03/2014 16:54:54 Reporta abuso | Link Permanente
Gianpierre
Usuario no registrado
Problemas con Response.Redirect()

Responder Citar
Hola,
Tengo un problema con un redirect, funciona muy bien en mi computadora, pero cuando lo publico al servidor no funciona, no estoy del todo seguro si el problema es completamente del redirect o del ExcelConvertor, les dejo ambos códigos:

ExcelConvertor
public string Convert(DataTable oDataTable, string directoryPath, string fileName)
{
string fullpath = "";

if (directoryPath.Substring(directoryPath.Length - 1,1) == @"\" ||directoryPath.Substring(directoryPath.Length - 1,1) == "/")
{
fullpath = directoryPath + fileName;
}
else
{
fullpath = directoryPath + @"\" + fileName;
}

StreamWriter SW;
SW=File.CreateText(fullpath);


            string comillas = char.ConvertFromUtf32(34);
StringBuilder oStringBuilder = new StringBuilder();

/********************************************************
* Start, check for border width
* ******************************************************/
int borderWidth = 0;

if (_ShowExcelTableBorder)
{
borderWidth = 1;
}
/********************************************************
* End, Check for border width
* ******************************************************/



            oStringBuilder.Append(@"<meta http-equiv=" + comillas + "Content-Type" + comillas + "content=" + comillas + "text/html; charset=utf-8" + comillas + "/>");

/********************************************************
* Start, Check for bold heading
* ******************************************************/
string boldTagStart = "";
string boldTagEnd = "";
if (_ExcelHeaderBold)
{
boldTagStart = "<B>";
boldTagEnd = "</B>";
}

/********************************************************
* End,Check for bold heading
* ******************************************************/

oStringBuilder.Append("<Table border=" + borderWidth + ">");

/*******************************************************************
* Start, Creating table header
* *****************************************************************/

oStringBuilder.Append("<TR>");

foreach(DataColumn oDataColumn in oDataTable.Columns)
{
oStringBuilder.Append("<TD>" + boldTagStart + oDataColumn.ColumnName + boldTagEnd + "</TD>");
}

oStringBuilder.Append("</TR>");

/*******************************************************************
* End, Creating table header
* *****************************************************************/

/*******************************************************************
* Start, Creating rows
* *****************************************************************/

foreach(DataRow oDataRow in oDataTable.Rows)
{
oStringBuilder.Append("<TR>");

foreach(DataColumn oDataColumn in oDataTable.Columns)
{
if (oDataRow[oDataColumn.ColumnName] is long)
{
oStringBuilder.Append("<TD align=right>" + oDataRow[oDataColumn.ColumnName] + "</TD>");
}
else
{
oStringBuilder.Append("<TD>" + oDataRow[oDataColumn.ColumnName] + "</TD>");
}
}

oStringBuilder.Append("</TR>");
}

/*******************************************************************
* End, Creating rows
* *****************************************************************/



oStringBuilder.Append("</Table>");
SW.WriteLine(oStringBuilder.ToString());
SW.Close();

return fullpath;
}

Redirect
 private void mvConsultarCF()
    {
        clsUsuariosDatos oBEUser = new clsUsuariosDatos();
        string fileName = "";

        fileName = "Lista_Datos" + ".xls";
        (new ExportDemo.Libraries.ExcelConvertor()).Convert(oBEUser.mdListaFichaDatosCF(), Server.MapPath("."), fileName);
        Response.Redirect(fileName);    
            

    }
Volver arriba