المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Web Service



C# Programming
03-31-2009, 03:43 AM
Hello! I can´t show videos in WS.
I have a GenericHandler:



using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public class VideoHandler : IHttpHandler
{
private localhost.wsDataReader example;

public void ProcessRequest (HttpContext context)
{
example = new localhost.wsDataReader();
context.Response.BinaryWrite((byte[]) example.ShowVideo() );
}

public bool IsReusable
{
get {
return false;
}
}
}

If we only execute it shows a window for download the video: open, save or cancel.

This .ashx uses the WebMethod called ShowVideo():

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data.SqlClient;

[WebService(Namespace = "http://localhost/wsDataReader/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class wsDataReader : System.Web.Services.WebService
{
public SqlConnection ConexionConBD;
public SqlCommand Orden;
public SqlDataReader Lector;

[WebMethod(Description = "this method returns a video using DataReader")]
public byte[] ShowVideo()
{
string Conexion ="Data Source=.\\SQLEXPRESS;AttachDbFilename=\"|DataDirectory|\\BDvideos.mdf\";Integra" +
"ted Security=True;User Instance=True";
ConexionConBD = new SqlConnection(Conexion);
string Consulta = "SELECT Video FROM Videos";
Orden = new SqlCommand(Consulta, ConexionConBD);
ConexionConBD.Open();
Lector = Orden.ExecuteReader();
Lector.Read();
return (byte[]) Lector["Video"];
}
}

I don´t want download the video. I only want show the video in a WindowsFormsApplication or in a Website (.aspx)...
What can I do?